Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,416 changes: 708 additions & 708 deletions ENTITIES_COMPLETED.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Game.Client/C_BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ public C_BaseEntity() {
public InlineArray32<ushort> OverrideSubMaterials;
[NetworkName("m_iHealth")]
public int Health;
public int GetHealth() => Health;
public int SetHealth(int amt) => Health = amt;
[NetworkName("m_iMaxHealth")]
public int MaxHealth;
[NetworkName("m_spawnflags")]
Expand Down
2 changes: 1 addition & 1 deletion Game.Client/C_BasePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ public virtual float GetFOV() {
public float VehicleViewFOV;
public int VehicleViewSavedFrame;

public int GetHealth() => Health;

public bool IsSuitEquipped() => Local.WearingSuit;

public TimeUnit_t GetLaggedMovementValue() => LaggedMovementValue;
Expand Down
8 changes: 8 additions & 0 deletions Game.Server/AI_BaseNPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5584,6 +5584,14 @@ public virtual Capability CapabilitiesGet() {
return capability;
}

public EntityCapabilities UsableNPCObjectCaps(EntityCapabilities baseCaps) {
if (IsAlive())
baseCaps |= EntityCapabilities.ImpulseUse;
return baseCaps;
}

public override EntityCapabilities ObjectCaps() => base.ObjectCaps() | EntityCapabilities.NotifyOnTransition;

public void NPCUse(BaseEntity? activator, BaseEntity? caller, UseType useType, float value) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions Game.Server/AI_PlayerAlly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ namespace Game.Server;
public class AI_PlayerAlly : AI_BaseActor
{
public override int SelectSchedule() => throw new NotImplementedException();

public override EntityCapabilities ObjectCaps() => UsableNPCObjectCaps(base.ObjectCaps());
}
26 changes: 26 additions & 0 deletions Game.Server/BaseCombatWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public partial class BaseCombatWeapon : BaseAnimating
{
public static readonly ConVar weapon_showproficiency = new("weapon_showproficiency", "0");

public OutputEvent OnPlayerUse = new();
public OutputEvent OnPlayerPickup = new();
public OutputEvent OnNPCPickup = new();
public OutputEvent OnCacheInteraction = new();

public static readonly new DataMap DataDesc = new(typeof(BaseCombatWeapon), BaseEntity.DataDesc, [
DEFINE.OUTPUT(nameof(OnPlayerUse), "OnPlayerUse", eventFuncs),
DEFINE.OUTPUT(nameof(OnPlayerPickup), "OnPlayerPickup", eventFuncs),
DEFINE.OUTPUT(nameof(OnNPCPickup), "OnNPCPickup", eventFuncs),
DEFINE.OUTPUT(nameof(OnCacheInteraction), "OnCacheInteraction", eventFuncs),
Expand Down Expand Up @@ -67,6 +69,30 @@ public static int GetAvailableWeaponsInBox(Span<BaseCombatWeapon?> list, in Vect
return count;
}

public override EntityCapabilities ObjectCaps() {
EntityCapabilities caps = base.ObjectCaps();
if (!IsFollowingEntity() && !HasSpawnFlags(SF_WEAPON_NO_PLAYER_PICKUP))
caps |= EntityCapabilities.ImpulseUse;

return caps;
}

public override void Use(BaseEntity? activator, BaseEntity? caller, UseType useType, float value) {
BasePlayer? player = ToBasePlayer(activator);

if (player != null) {
OnPlayerUse.FireOutput(activator, caller);

// Bump the weapon to try equipping it before picking it up physically. This is
// important in a few spots in the game where the player could potentially +use pickup
// and then THROW AWAY a vital weapon, rendering them unable to continue the game.
if (player.BumpWeapon(this))
OnPickedUp(player);
else
player.PickupObject(this);
}
}

public bool IsConstrained() => false;

public override bool IsWeapon() => true;
Expand Down
13 changes: 13 additions & 0 deletions Game.Server/BaseEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,15 @@ public void SetBlocksLOS(bool blocksLOS) {

public bool BlocksLOS() => !IsEFlagSet(EFL.DontBlockLOS);

public void SetAIWalkable(bool blocksLOS) {
if (blocksLOS)
RemoveEFlags(EFL.DontWalkOn);
else
AddEFlags(EFL.DontWalkOn);
}

public bool IsAIWalkable() => !IsEFlagSet(EFL.DontWalkOn);

public Vector3 AbsVelocity;
public QAngle AngVelocity;

Expand Down Expand Up @@ -2958,6 +2967,10 @@ public virtual void Use(BaseEntity? activator, BaseEntity? caller, UseType useTy
Parent.Get()?.Use(activator, caller, useType, value);
}

public bool IsFollowingEntity() => IsEffectActive(EntityEffects.BoneMerge) && (GetMoveType() == Source.MoveType.None) && GetMoveParent() != null;

public virtual bool OnControls(BaseEntity controls) => false;

public int ShouldToggle(UseType useType, int currentState) {
if (useType != UseType.Toggle && useType != UseType.Set) {
if ((currentState != 0 && useType == UseType.On) || (currentState == 0 && useType == UseType.Off))
Expand Down
47 changes: 46 additions & 1 deletion Game.Server/FuncBreak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,49 @@
namespace Game.Server;

[LinkEntityToClass("func_breakable")]
public class Breakable : BaseEntity, IBreakableWithPropData;
public class Breakable : BaseEntity, IBreakableWithPropData
{
public void SetDmgModBullet(float dmgMod) => DmgModBullet = dmgMod;
public void SetDmgModClub(float dmgMod) => DmgModClub = dmgMod;
public void SetDmgModExplosive(float dmgMod) => DmgModExplosive = dmgMod;
public float GetDmgModBullet() => DmgModBullet;
public float GetDmgModClub() => DmgModClub;
public float GetDmgModExplosive() => DmgModExplosive;
public void SetExplosiveRadius(float radius) => ExplodeRadius = radius;
public void SetExplosiveDamage(float damage) => ExplosionMagnitude = (int)damage;
public float GetExplosiveRadius() => ExplodeRadius;
public float GetExplosiveDamage() => ExplosionMagnitude;
public void SetPhysicsDamageTable(ReadOnlySpan<char> tableName) => PhysicsDamageTableName = tableName.IsEmpty ? null : new(tableName);
public ReadOnlySpan<char> GetPhysicsDamageTable() => PhysicsDamageTableName;
public void SetBreakableModel(ReadOnlySpan<char> model) => BreakableModel = model.IsEmpty ? null : new(model);
public ReadOnlySpan<char> GetBreakableModel() => BreakableModel;
public void SetBreakableSkin(int skin) => BreakableSkin = skin;
public int GetBreakableSkin() => BreakableSkin;
public void SetBreakableCount(int count) => BreakableCount = count;
public int GetBreakableCount() => BreakableCount;
public void SetMaxBreakableSize(int size) => MaxBreakableSize = size;
public int GetMaxBreakableSize() => MaxBreakableSize;
public void SetPropDataBlocksLOS(bool blocksLOS) => SetBlocksLOS(blocksLOS);
public void SetPropDataIsAIWalkable(bool blocksLOS) => SetAIWalkable(blocksLOS);
public void SetBasePropData(ReadOnlySpan<char> propdata) => BasePropData = propdata.IsEmpty ? null : new(propdata);
public ReadOnlySpan<char> GetBasePropData() => BasePropData;
public void SetInteraction(PropDataInteractions interaction) => Interactions |= (1 << (int)interaction);
public bool HasInteraction(PropDataInteractions interaction) => (Interactions & (1 << (int)interaction)) != 0;
public void SetPhysicsMode(PhysicsMultiplayerMode mode) { }
public PhysicsMultiplayerMode GetPhysicsMode() => PhysicsMultiplayerMode.Solid;
public void SetMultiplayerBreakMode(MultiplayerBreak mode) { }
public MultiplayerBreak GetMultiplayerBreakMode() => MultiplayerBreak.Default;

protected float DmgModBullet;
protected float DmgModClub;
protected float DmgModExplosive;
protected string? PhysicsDamageTableName;
protected string? BreakableModel;
protected int BreakableSkin;
protected int BreakableCount;
protected int MaxBreakableSize;
protected string? BasePropData;
protected int Interactions;
protected int ExplosionMagnitude;
protected float ExplodeRadius;
}
11 changes: 10 additions & 1 deletion Game.Server/FuncTrackTrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public class FuncTrackTrain : BaseEntity
public const int SF_TRACKTRAIN_USE_MAXSPEED_FOR_PITCH = 0x0100;
public const int SF_TRACKTRAIN_UNBLOCKABLE_BY_PLAYER = 0x0200;

public const int TRAIN_ACTIVE = 0x80;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better to have as an enum actually

public const int TRAIN_NEW = 0xc0;
public const int TRAIN_OFF = 0x00;
public const int TRAIN_NEUTRAL = 0x01;
public const int TRAIN_SLOW = 0x02;
public const int TRAIN_MEDIUM = 0x03;
public const int TRAIN_FAST = 0x04;
public const int TRAIN_BACK = 0x05;

const float TRAIN_MAXSPEED = 1000;

public static readonly SendTable DT_FuncTrackTrain = new(DT_BaseEntity, []);
Expand Down Expand Up @@ -890,7 +899,7 @@ public void SetControls(BaseEntity controls) {
ControlMaxs = controls.WorldAlignMaxs() + offset;
}

public bool OnControls(BaseEntity test) {
public override bool OnControls(BaseEntity test) {
Vector3 offset = test.GetLocalOrigin() - GetLocalOrigin();

if ((SpawnFlags & SF_TRACKTRAIN_NOCONTROL) != 0)
Expand Down
4 changes: 4 additions & 0 deletions Game.Server/GarrysMod/GMOD_Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public override void PlayerRunCommand(UserCmd ucmd, IMoveHelper moveHelper) {
base.PlayerRunCommand(ucmd, moveHelper);
}

public override void PickupObject(BaseEntity obj, bool limitMassAndSize = true) {
HL2_PickupObject(obj, limitMassAndSize);
}

public override void CheckChatText(ReadOnlySpan<char> text) {
if (!stristr(text, "bloxwich").IsEmpty)
AwardAchievement((int)GMODAchievementID.GMA_SAY_1, 1);
Expand Down
Loading
Loading