Skip to content
Closed
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
136 changes: 68 additions & 68 deletions ENTITIES_COMPLETED.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Game.Server/BaseFlex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,19 @@ bool ProcessSequenceSceneEvent(SceneEventInfo? info, ChoreoScene? scene, ChoreoE
return true;
}

// todo: response parameter (AI_Response), it needs the response system ported first
public float PlayScene(ReadOnlySpan<char> scene, float delay = 0.0f, IRecipientFilter? filter = null) {
EHANDLE sceneEnt = new();
return InstancedScriptedScene(this, scene, ref sceneEnt, delay, false, false, filter);
}

public float PlayAutoGeneratedSoundScene(ReadOnlySpan<char> soundname) {
EHANDLE sceneEnt = new();
return InstancedAutoGeneratedSoundScene(this, soundname, ref sceneEnt);
}

public bool ExitSceneSequence() => true;

public bool EnterSceneSequence(ChoreoScene scene, ChoreoEvent ev, bool restart = false) {
AI_BaseNPC? myNpc = MyNPCPointer();

Expand Down
2 changes: 2 additions & 0 deletions Game.Server/GenericActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class GenericActor : AI_BaseActor

public override int GetSoundInterests() => 0;

public override void HandleAnimEvent(ref AnimEvent animEvent) => base.HandleAnimEvent(ref animEvent);

public override void Spawn() {
Precache();

Expand Down
2 changes: 2 additions & 0 deletions Game.Server/LogicAuto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum SF

string? globalstate;

public override EntityCapabilities ObjectCaps() => base.ObjectCaps() & ~EntityCapabilities.AcrossTransition;

public static readonly new DataMap DataDesc = new(typeof(LogicAuto), BaseEntity.DataDesc, [
DEFINE.KEYFIELD(nameof(globalstate), FieldType.String, "globalstate"),
DEFINE.OUTPUT(nameof(OnMapSpawn), "OnMapSpawn", eventFuncs),
Expand Down
4 changes: 4 additions & 0 deletions Game.Server/NPC_GMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public override int GetSoundInterests() {
return 0;
}

public override void HandleAnimEvent(ref AnimEvent animEvent) {
base.HandleAnimEvent(ref animEvent);
}

public override void Spawn() {
Precache();

Expand Down
32 changes: 31 additions & 1 deletion Game.Server/SceneEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ public static void PrecacheInstancedScene(ReadOnlySpan<char> scene) {
}

public static float InstancedScriptedScene(BaseFlex? actor, ReadOnlySpan<char> sceneName, ref EHANDLE sceneEnt, float postDelay = 0.0f, bool isBackground = false, bool multiplayer = false, IRecipientFilter? filter = null) {
InstancedSceneEntity scene = (InstancedSceneEntity)BaseEntity.CreateNoSpawn("instanced_scripted_scene", vec3_origin, vec3_angle)!;
InstancedSceneEntity? scene = (InstancedSceneEntity?)BaseEntity.CreateNoSpawn("instanced_scripted_scene", vec3_origin, vec3_angle);
#if GMOD_DLL
if (scene == null)
return 0.0f;
#endif

if (actor != null) {
Span<char> instanceFilename = stackalloc char[ChoreoScene.MAX_SCENE_FILENAME];
Expand All @@ -116,6 +120,8 @@ public static float InstancedScriptedScene(BaseFlex? actor, ReadOnlySpan<char> s
scene.Activate();
scene.IsBackgroundScene = isBackground;

// todo: response parameter (SetPreDelay from AI_Response::GetPreDelay, SetBreakOnNonIdle), it needs the response system ported first

scene.SetBackground(isBackground);
scene.SetRecipientFilter(filter);

Expand All @@ -126,6 +132,30 @@ public static float InstancedScriptedScene(BaseFlex? actor, ReadOnlySpan<char> s
return scene.EstimateLength();
}

public static float InstancedAutoGeneratedSoundScene(BaseFlex? actor, ReadOnlySpan<char> soundname, ref EHANDLE sceneEnt) {
if (actor == null) {
Warning($"InstancedAutoGeneratedSoundScene: Expecting non-NULL pActor for sound {soundname}\n");
return 0;
}

InstancedSceneEntity scene = (InstancedSceneEntity)BaseEntity.CreateNoSpawn("instanced_scripted_scene", vec3_origin, vec3_angle)!;

scene.SceneFile = $"AutoGenerated({soundname})";

scene.Owner.Set(actor);
scene.HadOwner = true;

scene.GenerateSoundScene(actor, soundname);

scene.Spawn();
scene.Activate();
scene.StartPlayback();

sceneEnt.Set(scene);

return scene.EstimateLength();
}

public static void StopScriptedScene(BaseFlex? actor, EHANDLE sceneEnt) {
if (sceneEnt.Get() is SceneEntity scene) {
Scene_Printf($"{scene.SceneFile} : stop scripted scene\n");
Expand Down
13 changes: 13 additions & 0 deletions Game.Server/Triggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,19 @@ public enum SF
]);
public override DataMap? GetDataDescMap() => DataDesc;

public override int DrawDebugTextOverlays() {
int text_offset = base.DrawDebugTextOverlays();

if ((DebugOverlays & DebugOverlayBits.Text) != 0) {
Span<char> tempstr = stackalloc char[255];
sprintf(tempstr, "Time: %3.2f").F(LookTime - Math.Max(0, LookTimeTotal));
EntityText(text_offset, tempstr, 0);
text_offset++;
}

return text_offset;
}

//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions Game.Shared/GarrysMod/LuaEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ static int Entity__Fire(ILuaInterface lua) {
return 0;
}

[LuaMethod]
static int Entity__PlayScene(ILuaInterface lua) {
BaseEntity ent = Get_Entity(1, false)!;
if (ent.GetBaseAnimating() is not BaseFlex flex)
return 0;

float delay = lua.GetType(3) == LuaType.Number ? (float)lua.CheckNumber(3) : 0.0f;
EHANDLE sceneEnt = new();
float duration = InstancedScriptedScene(flex, lua.CheckString(2), ref sceneEnt, delay);
lua.PushNumber(duration);
Push_Entity(sceneEnt.Get());
return 2;
}

[LuaMethod]
static int Entity__StartMotionController(ILuaInterface lua) {
BaseEntity ent = Get_Entity(1, false)!;
Expand Down
21 changes: 16 additions & 5 deletions Game.Shared/GarrysMod/WeaponPhysGun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public override void Activate() {
base.Activate();
}

#if GAME_DLL
public override void OnRestore() {
base.OnRestore();
DropEntity();
CreatePhysBeam();
}
#endif

public
#if CLIENT_DLL
Expand All @@ -89,6 +96,7 @@ public EHANDLE CreatePhysBeam() {
if ((GetEFlags() & EFL.DirtyAbsTransform) != 0)
CalcAbsolutePosition();

// todo: PhysBeam = CPhysBeam::Create(GetOwnerEntity(), GetAbsOrigin()), it needs CPhysBeam ported first
return default;
}
public override bool Deploy() {
Expand All @@ -102,7 +110,7 @@ public override void Drop(in Vector3 velocity) {
base.Drop(velocity);
}
public void DropEntity(){

// todo: PhysgunDrop hook, EnablePhysBeam, detach the grabbed entity from the controller, SetPhysicsAttacker and reset the handles, it needs CPhysGunControllerPoint ported first
}
public override float GetFireRate() => 0.01f;
public override ReadOnlySpan<char> GetHoldType() => "physgun";
Expand All @@ -113,28 +121,31 @@ public override bool Holster(BaseCombatWeapon switchingTo) {
return base.Holster(switchingTo);
}
public override void ItemPostFrame() {
// todo
base.ItemPostFrame();
}
public override void Precache() {
base.Precache();
}
public override void PrimaryAttack() {
// todo
base.PrimaryAttack();
}
public override bool Reload() {
return base.Reload();
}
public void RemovePhysBeam(){

// todo: remove the beam entity, it needs CPhysBeam ported first
}
public override void SecondaryAttack() {
// todo
base.SecondaryAttack();
}
public override void UpdateOnRemove() {
base.UpdateOnRemove();
}
public void UpdatePosition(){ }
public void UpdateRotation(){ }
public bool ValidatePhysObj() => false;
public void UpdatePosition(){ } // todo
public void UpdateRotation(){ } // todo
public bool ValidatePhysObj() => false; // todo
}
#endif
2 changes: 1 addition & 1 deletion Utils/Scripts/gen_entities_checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def find_src(c): return ddsrc[c][1] if c in ddsrc else obsfile.get(c)
# C#: classes, links, methods, string literals
# ---------------------------------------------------------------------------------------------
cs = {}; netname = {}
DECL = re.compile(r'^\s*(?:\[[^\]]*\]\s*)*(?:(?:public|private|protected|internal|static|override|virtual|abstract|new|sealed|unsafe|extern|partial|async|readonly)\s+)*[\w<>\[\],.?]+(?:<[^()]*>)?[?]?\s+(\w+)\s*(?:<[^()]*>)?\s*\(')
DECL = re.compile(r'^\s*(?:\[[^\]]*\]\s*)*(?:(?:public|private|protected|internal|static|override|virtual|abstract|new|sealed|unsafe|extern|partial|async|readonly|ref)\s+)*[\w<>\[\],.?]+(?:<[^()]*>)?[?]?\s+(\w+)\s*(?:<[^()]*>)?\s*\(')
CLS = re.compile(r'\b(?:class|struct)\s+(\w+)')
NOTMETHOD = {'if', 'while', 'for', 'foreach', 'switch', 'return', 'using', 'lock', 'catch', 'new', 'class', 'struct'}
def preprocess(raw):
Expand Down
Loading