private bool IsAllSpawnedDead() { for (int index = 0; index < this.Spawned.Count; index = index - 1 + 1) { MurdererDomain murdererDomain = this.Spawned[index]; if (!Object.op_Equality((Object)murdererDomain, (Object)null) && !Object.op_Equality((Object)((Component)murdererDomain).get_transform(), (Object)null) && (murdererDomain.MurdererContext != null && !Object.op_Equality((Object)murdererDomain.MurdererContext.Body, (Object)null)) && (!murdererDomain.MurdererContext.Body.IsDestroyed && !murdererDomain.MurdererContext.Body.IsDead())) { return(false); } this.Spawned.RemoveAt(index); } return(true); }
private bool IsAllSpawnedDead() { for (int i = 0; i < this.Spawned.Count; i++) { MurdererDomain item = this.Spawned[i]; if (!(item == null) && !(item.transform == null) && item.MurdererContext != null && !(item.MurdererContext.Body == null) && !item.MurdererContext.Body.IsDestroyed && !item.MurdererContext.Body.IsDead()) { return(false); } this.Spawned.RemoveAt(i); i--; } return(true); }
public MurdererContext(HTNPlayer body, MurdererDomain domain) { int length = Enum.GetValues(typeof(Facts)).Length; if (this._worldState == null || (int)this._worldState.Length != length) { this._worldState = new byte[length]; this._previousWorldState = new byte[length]; if (MurdererContext._worldStateChanges == null) { MurdererContext._worldStateChanges = new Stack <WorldStateInfo> [length]; for (int i = 0; i < length; i++) { MurdererContext._worldStateChanges[i] = new Stack <WorldStateInfo>(5); } } } this._decompositionScore = 2147483647; this.Body = body; this.Domain = domain; this.PlanState = PlanStateType.NoPlan; if (this.Memory == null || this.Memory.MurdererContext != this) { this.Memory = new MurdererMemory(this); } if (this.Location == null) { float single = Single.MaxValue; foreach (AiLocationManager manager in AiLocationManager.Managers) { Vector3 vector3 = manager.transform.position - this.Body.transform.position; float single1 = vector3.sqrMagnitude; if (single1 >= single) { continue; } single = single1; this.Location = manager; } } this._worldState[31] = 1; this._previousWorldState[31] = 1; }
public MurdererContext(HTNPlayer body, MurdererDomain domain) { int length = System.Enum.GetValues(typeof(Facts)).Length; if (this._worldState == null || this._worldState.Length != length) { this._worldState = new byte[length]; this._previousWorldState = new byte[length]; if (MurdererContext._worldStateChanges == null) { MurdererContext._worldStateChanges = new Stack <WorldStateInfo> [length]; for (int index = 0; index < length; ++index) { MurdererContext._worldStateChanges[index] = new Stack <WorldStateInfo>(5); } } } this._decompositionScore = int.MaxValue; this.Body = body; this.Domain = domain; this.PlanState = (PlanStateType)0; if (this.Memory == null || this.Memory.MurdererContext != this) { this.Memory = new MurdererMemory(this); } if (Object.op_Equality((Object)this.Location, (Object)null)) { float num = float.MaxValue; foreach (AiLocationManager manager in AiLocationManager.Managers) { Vector3 vector3 = Vector3.op_Subtraction(((Component)manager).get_transform().get_position(), ((Component)this.Body).get_transform().get_position()); float sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude(); if ((double)sqrMagnitude < (double)num) { num = sqrMagnitude; this.Location = manager; } } } this._worldState[31] = (byte)1; this._previousWorldState[31] = (byte)1; }
public void SpawnScientist() { if (this.Spawned == null || this.Spawned.Count >= this.MaxPopulation) { Debug.LogWarning((object)"Attempted to spawn a Scientist, but the spawner was full!"); } else { if (!AI.npc_enable) { return; } int num = this.MaxPopulation - this.Spawned.Count; for (int index = 0; index < num; ++index) { Vector3 pos; Quaternion rot; if (!Object.op_Equality((Object)this.GetSpawnPoint(out pos, out rot), (Object)null)) { BaseEntity entity = GameManager.server.CreateEntity(this.MurdererPrefab.resourcePath, pos, rot, false); MurdererDomain component = (MurdererDomain)((Component)entity).GetComponent <MurdererDomain>(); if (Object.op_Implicit((Object)component)) { entity.enableSaving = false; ((Component)entity).get_gameObject().AwakeFromInstantiate(); entity.Spawn(); component.Movement = this.Movement; component.MovementRadius = this.MovementRadius; component.ReducedLongRangeAccuracy = this.ReducedLongRangeAccuracy; this.Spawned.Add(component); } else { entity.Kill(BaseNetworkable.DestroyMode.None); break; } } } } }
public void SpawnScientist() { Vector3 vector3; Quaternion quaternion; if (this.Spawned == null || this.Spawned.Count >= this.MaxPopulation) { Debug.LogWarning("Attempted to spawn a Scientist, but the spawner was full!"); return; } if (!ConVar.AI.npc_enable) { return; } int maxPopulation = this.MaxPopulation - this.Spawned.Count; for (int i = 0; i < maxPopulation; i++) { if (this.GetSpawnPoint(out vector3, out quaternion) != null) { BaseEntity baseEntity = GameManager.server.CreateEntity(this.MurdererPrefab.resourcePath, vector3, quaternion, false); MurdererDomain component = baseEntity.GetComponent <MurdererDomain>(); if (!component) { baseEntity.Kill(BaseNetworkable.DestroyMode.None); return; } baseEntity.enableSaving = false; baseEntity.gameObject.AwakeFromInstantiate(); baseEntity.Spawn(); component.Movement = this.Movement; component.MovementRadius = this.MovementRadius; component.ReducedLongRangeAccuracy = this.ReducedLongRangeAccuracy; this.Spawned.Add(component); } } }
private IEnumerator EquipWeapon(HTNPlayer target) { yield return((object)CoroutineEx.waitForSeconds(0.25f)); if (!Object.op_Equality((Object)target, (Object)null) && !target.IsDestroyed && (!target.IsDead() && !target.IsWounded()) && (!Object.op_Equality((Object)target.inventory, (Object)null) && target.inventory.containerBelt != null)) { Item slot = target.inventory.containerBelt.GetSlot(0); if (slot != null) { target.UpdateActiveItem(slot.uid); yield return((object)CoroutineEx.waitForSeconds(0.25f)); MurdererDomain aiDomain = target.AiDomain as MurdererDomain; if (Object.op_Implicit((Object)aiDomain)) { if (slot.info.category == ItemCategory.Weapon) { BaseEntity heldEntity = slot.GetHeldEntity(); if (heldEntity is BaseProjectile) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true); aiDomain.ReloadFirearm(); } else if (heldEntity is BaseMelee) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true); Chainsaw chainsaw = heldEntity as Chainsaw; if (Object.op_Implicit((Object)chainsaw)) { chainsaw.ServerNPCStart(); } } else if (heldEntity is ThrownWeapon) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true); } } else if (slot.info.category == ItemCategory.Medical) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true); } else if (slot.info.category == ItemCategory.Tool) { BaseEntity heldEntity = slot.GetHeldEntity(); if (heldEntity is BaseMelee) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true); Chainsaw chainsaw = heldEntity as Chainsaw; if (Object.op_Implicit((Object)chainsaw)) { chainsaw.ServerNPCStart(); } } else { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true); } } } } } }
private IEnumerator EquipWeapon(HTNPlayer target) { yield return(CoroutineEx.waitForSeconds(0.25f)); if (target == null || target.IsDestroyed || target.IsDead() || target.IsWounded() || target.inventory == null || target.inventory.containerBelt == null) { yield break; } Item item = target.inventory.containerBelt.GetSlot(0); if (item == null) { yield break; } target.UpdateActiveItem(item.uid); yield return(CoroutineEx.waitForSeconds(0.25f)); MurdererDomain aiDomain = target.AiDomain as MurdererDomain; if (aiDomain) { if (item.info.category == ItemCategory.Weapon) { BaseEntity heldEntity = item.GetHeldEntity(); if (heldEntity is BaseProjectile) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true); aiDomain.ReloadFirearm(); } else if (heldEntity is BaseMelee) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true); Chainsaw chainsaw = heldEntity as Chainsaw; if (chainsaw) { chainsaw.ServerNPCStart(); } } else if (heldEntity is ThrownWeapon) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true); } } else if (item.info.category == ItemCategory.Medical) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true); } else if (item.info.category == ItemCategory.Tool) { BaseEntity baseEntity = item.GetHeldEntity(); if (!(baseEntity is BaseMelee)) { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true); } else { aiDomain.MurdererContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true); Chainsaw chainsaw1 = baseEntity as Chainsaw; if (chainsaw1) { chainsaw1.ServerNPCStart(); } } } } }