@@ -77,19 +77,6 @@ public static class AI_BaseNPCGlobals
7777{
7878 // TODO: Enum these
7979 // need a good name for its enum type
80- public const int SF_NPC_WAIT_TILL_SEEN = 1 << 0 ;
81- public const int SF_NPC_GAG = 1 << 1 ;
82- public const int SF_NPC_FALL_TO_GROUND = 1 << 2 ;
83- public const int SF_NPC_DROP_HEALTHKIT = 1 << 3 ;
84- public const int SF_NPC_START_EFFICIENT = 1 << 4 ;
85- public const int SF_NPC_WAIT_FOR_SCRIPT = 1 << 7 ;
86- public const int SF_NPC_LONG_RANGE = 1 << 8 ;
87- public const int SF_NPC_FADE_CORPSE = 1 << 9 ;
88- public const int SF_NPC_ALWAYSTHINK = 1 << 10 ;
89- public const int SF_NPC_TEMPLATE = 1 << 11 ;
90- public const int SF_NPC_ALTCOLLISION = 1 << 12 ;
91- public const int SF_NPC_NO_WEAPON_DROP = 1 << 13 ;
92- public const int SF_NPC_NO_PLAYER_PUSHAWAY = 1 << 14 ;
9380
9481 public const string PLAYER_SQUADNAME = "player_squad" ;
9582
@@ -334,6 +321,24 @@ public bool EnumEntity(IHandleEntity? handleEntity) {
334321[ NetworkName ( "CAI_BaseNPC" ) ]
335322public class AI_BaseNPC : BaseCombatCharacter , IAI_MovementSink
336323{
324+ [ Flags ]
325+ public enum SF
326+ {
327+ WaitTillSeen = 1 << 0 ,
328+ Gag = 1 << 1 ,
329+ FallToGround = 1 << 2 ,
330+ DropHealthkit = 1 << 3 ,
331+ StartEfficient = 1 << 4 ,
332+ WaitForScript = 1 << 7 ,
333+ LongRange = 1 << 8 ,
334+ FadeCorpse = 1 << 9 ,
335+ AlwaysThink = 1 << 10 ,
336+ Template = 1 << 11 ,
337+ AltCollision = 1 << 12 ,
338+ NoWeaponDrop = 1 << 13 ,
339+ NoPlayerPushaway = 1 << 14 ,
340+ }
341+
337342 public static ReadOnlySpan < char > GetActivityName ( Activity actID ) {
338343 if ( actID == Activity . ACT_INVALID )
339344 return "ACT_INVALID" ;
@@ -2638,7 +2643,7 @@ public static void InitSchedulingTables() {
26382643
26392644 public NPCState GetIdealState ( ) => IdealNPCState ;
26402645
2641- public override bool IsTemplate ( ) => HasSpawnFlags ( SF_NPC_TEMPLATE ) ;
2646+ public override bool IsTemplate ( ) => HasSpawnFlags ( SF . Template ) ;
26422647
26432648 public static bool FindSpotForNPCInRadius ( out Vector3 result , in Vector3 startPos , AI_BaseNPC npc , float radius , bool outOfPlayerViewcone = false ) {
26442649 BasePlayer ? player = npc . AI_GetClosestPlayer ( ) ;
@@ -2699,7 +2704,7 @@ public bool CineCleanup() {
26992704 throw new NotImplementedException ( ) ;
27002705
27012706 if ( oldCine != null && ! string . IsNullOrEmpty ( oldCine . Play ) && oldCine . PlayedSequence ( ) ) {
2702- if ( ! oldCine . HasSpawnFlags ( AI_ScriptedSequence . SF_SCRIPT_DONT_TELEPORT_AT_END ) ) {
2707+ if ( ! oldCine . HasSpawnFlags ( AI_ScriptedSequence . SF . DontTeleportAtEnd ) ) {
27032708 GetBonePosition ( 0 , out Vector3 newOrigin , out _ ) ;
27042709
27052710 Vector3 oldOrigin = GetLocalOrigin ( ) ;
@@ -2757,7 +2762,7 @@ public bool CineCleanup() {
27572762 SetCondition ( ( int ) SCOND_t . COND_LIGHT_DAMAGE ) ;
27582763 }
27592764
2760- RemoveSpawnFlags ( SF_NPC_WAIT_FOR_SCRIPT ) ;
2765+ RemoveSpawnFlags ( SF . WaitForScript ) ;
27612766
27622767 if ( destroyCine )
27632768 Util . Remove ( oldCine ) ;
@@ -3584,7 +3589,7 @@ public void UnlockBestSound() {
35843589 public AI_MoveEfficiency GetMoveEfficiency ( ) => MoveEfficiency ;
35853590 public void SetMoveEfficiency ( AI_MoveEfficiency efficiency ) => MoveEfficiency = efficiency ;
35863591
3587- public bool IsFlaggedEfficient ( ) => HasSpawnFlags ( SF_NPC_START_EFFICIENT ) ;
3592+ public bool IsFlaggedEfficient ( ) => HasSpawnFlags ( SF . StartEfficient ) ;
35883593
35893594 public void RemoveSleepFlags ( AI_SleepFlags flags ) => SleepFlags &= ~ flags ;
35903595 public bool HasSleepFlags ( AI_SleepFlags flags ) => ( SleepFlags & flags ) == flags ;
@@ -5956,7 +5961,7 @@ public virtual bool ShouldPlayerAvoid() {
59565961 if ( IsInLockedScene ( ) == true )
59575962 return true ;
59585963
5959- if ( HasSpawnFlags ( SF_NPC_ALTCOLLISION ) )
5964+ if ( HasSpawnFlags ( SF . AltCollision ) )
59605965 return true ;
59615966
59625967 return false ;
@@ -7168,7 +7173,7 @@ public void CheckOnGround() {
71687173
71697174 public virtual bool ShouldPlayIdleSound ( ) {
71707175 if ( ( NPCState == NPCState . Idle || NPCState == NPCState . Alert ) &&
7171- RandomInt ( 0 , 99 ) == 0 && ! HasSpawnFlags ( SF_NPC_GAG ) ) {
7176+ RandomInt ( 0 , 99 ) == 0 && ! HasSpawnFlags ( SF . Gag ) ) {
71727177 return true ;
71737178 }
71747179
@@ -7187,7 +7192,7 @@ public bool FOkToMakeSound(SentencePriority soundPriority = SentencePriority.Nor
71877192 }
71887193 }
71897194
7190- if ( HasSpawnFlags ( SF_NPC_GAG ) && ( NPCState != NPCState . Combat ) )
7195+ if ( HasSpawnFlags ( SF . Gag ) && ( NPCState != NPCState . Combat ) )
71917196 return false ;
71927197
71937198 return true ;
@@ -7205,7 +7210,7 @@ public virtual void DeathSound(in TakeDamageInfo info) { }
72057210 public virtual void LostEnemySound ( ) { }
72067211 public virtual void FoundEnemySound ( ) { }
72077212
7208- public virtual bool ShouldAlwaysThink ( ) => HasSpawnFlags ( SF_NPC_ALWAYSTHINK ) ;
7213+ public virtual bool ShouldAlwaysThink ( ) => HasSpawnFlags ( SF . AlwaysThink ) ;
72097214
72107215 static readonly int [ ] SenseConditionsToClear = [
72117216 ( int ) SCOND_t . COND_SEE_HATE ,
@@ -7522,7 +7527,7 @@ public virtual void NPCInit() {
75227527 DistTooFar = 1024.0f ;
75237528 SetDistLook ( 2048.0f ) ;
75247529
7525- if ( HasSpawnFlags ( SF_NPC_LONG_RANGE ) ) {
7530+ if ( HasSpawnFlags ( SF . LongRange ) ) {
75267531 DistTooFar = 1e9f ;
75277532 SetDistLook ( 6000.0f ) ;
75287533 }
@@ -7553,15 +7558,15 @@ public virtual void NPCInit() {
75537558
75547559 ForceGatherConditions ( ) ;
75557560
7556- if ( HasSpawnFlags ( SF_NPC_WAIT_FOR_SCRIPT ) ) {
7561+ if ( HasSpawnFlags ( SF . WaitForScript ) ) {
75577562 string ? startSequence = AI_ScriptedSequence . GetSpawnPreIdleSequenceForScript ( this ) ;
75587563 if ( startSequence != null )
75597564 SetSequence ( LookupSequence ( startSequence ) ) ;
75607565 }
75617566
75627567 CreateVPhysics ( ) ;
75637568
7564- if ( HasSpawnFlags ( SF_NPC_START_EFFICIENT ) )
7569+ if ( HasSpawnFlags ( SF . StartEfficient ) )
75657570 SetEfficiency ( AI_Efficiency . Efficient ) ;
75667571
75677572 FadeCorpse = ShouldFadeOnDeath ( ) ;
@@ -7606,7 +7611,7 @@ public virtual void PostNPCInit() { }
76067611 public virtual void StartNPC ( ) {
76077612 if ( ( GetMoveType ( ) != Source . MoveType . Fly ) && ( GetMoveType ( ) != Source . MoveType . FlyGravity ) &&
76087613 ( CapabilitiesGet ( ) & Server . Capability . MoveFly ) == 0 &&
7609- ! HasSpawnFlags ( SF_NPC_FALL_TO_GROUND ) && ! IsWaitingToRappel ( ) && GetMoveParent ( ) == null ) {
7614+ ! HasSpawnFlags ( SF . FallToGround ) && ! IsWaitingToRappel ( ) && GetMoveParent ( ) == null ) {
76107615 Vector3 origin = GetLocalOrigin ( ) ;
76117616
76127617 if ( ! GetMoveProbe ( ) ! . FloorPoint ( origin + new Vector3 ( 0 , 0 , 0.1f ) , Mask . NPCSolid , 0 , - 2048 , out origin ) ) {
@@ -7649,7 +7654,7 @@ public virtual void StartNPC() {
76497654 ScriptArrivalActivity = AIN_DEF_ACTIVITY ;
76507655 ScriptArrivalSequence = null ;
76517656
7652- if ( HasSpawnFlags ( SF_NPC_WAIT_FOR_SCRIPT ) ) {
7657+ if ( HasSpawnFlags ( SF . WaitForScript ) ) {
76537658 SetState ( NPCState . Idle ) ;
76547659 Activity = IdealActivity ;
76557660 IdealSequence = GetSequence ( ) ;
@@ -8172,7 +8177,7 @@ public bool ConditionInterruptsCurSchedule(int condition) {
81728177 }
81738178
81748179 public void TestPlayerPushing ( BaseEntity ? entity ) {
8175- if ( HasSpawnFlags ( SF_NPC_NO_PLAYER_PUSHAWAY ) )
8180+ if ( HasSpawnFlags ( SF . NoPlayerPushaway ) )
81768181 return ;
81778182
81788183 BasePlayer ? player = ToBasePlayer ( entity ) ;
@@ -8846,7 +8851,7 @@ public void UpdateSleepState(bool inPVS) {
88468851 }
88478852 }
88488853
8849- if ( ( GetSoundInterests ( ) & ( int ) SoundInstanceType . Danger ) != 0 && ! HasSpawnFlags ( SF_NPC_WAIT_TILL_SEEN ) ) {
8854+ if ( ( GetSoundInterests ( ) & ( int ) SoundInstanceType . Danger ) != 0 && ! HasSpawnFlags ( SF . WaitTillSeen ) ) {
88508855 int sound = SoundEnt . ActiveList ( ) ;
88518856
88528857 while ( sound != SOUNDLIST_EMPTY ) {
0 commit comments