public void Release() { LocalAsset = null; var pawns = _pawns.Keys.ToArray(); _pawns.Clear(); Array.ForEach(pawns, UnityEngine.Object.Destroy); }
public void SetLocalPawn(PawnObserver pawn, UIHealthBarController healthBar) { if (LocalAsset != null) { UnityEngine.Object.Destroy(LocalAsset); } LocalAsset = pawn; SetPawn(PhotonNetwork.player, pawn, healthBar); }
public void DropPawn(PawnObserver pawn) { var state = GetState(pawn); if (state == null) { return; } state.Release(); _pawns.Remove(pawn); }
internal static Pawn GetPawn(this PawnObserver _this) { if (_pawn == null) { _pawn = typeof(PawnObserver).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic); if (_pawn == null) { Log.ErrorOnce("Unable to reflect PawnObserver.pawn!", 305432421); } } return((Pawn)_pawn.GetValue(_this)); }
public void RemoteUpdate(PawnObserver pawn, int health) { if (pawn == null) { return; } var state = GetState(pawn); state.UpdateHealth(health - _pawns[pawn].Health); Debug.Log("<color=blue>HitPawn REMOTE</color>"); }
// Token: 0x06000DC4 RID: 3524 RVA: 0x000456A8 File Offset: 0x000438A8 internal static void _ObserveSurroundingThings(this PawnObserver _this) { Pawn pawn = _this.GetPawn(); if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight)) { return; } Room room = RoomQuery.RoomAt(pawn.Position); int num = 0; while ((float)num < 100f) { IntVec3 c = pawn.Position + GenRadial.RadialPattern[num]; if (c.InBounds()) { if (RoomQuery.RoomAt(c) == room) { List <Thing> thingList = c.GetThingList(); for (int i = 0; i < thingList.Count; i++) { IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver; if (thoughtGiver != null) { Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought(); if (thought_Memory != null) { if (thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse) { if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust)) { if (((pawn.GetHashCode() ^ (GenDate.DayOfYear + GenDate.CurrentYear + (int)(GenDate.CurrentDayPercent * 5) * 60) * 391) % 1000) == 0) { pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized)); pawn.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.RecentlyDesensitized, (Pawn)null); } } } pawn.needs.mood.thoughts.memories.TryGainMemoryThought(thought_Memory, null); } } } } } num++; } }
public static void DesensitizeViaCorpse(PawnObserver __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight)) { return; } RoomGroup roomGroup = pawn.GetRoomGroup(); Map map = pawn.Map; int num = 0; while ((float)num < 100f) { IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num]; if (intVec.InBounds(map)) { if (intVec.GetRoomGroup(map) == roomGroup) { if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0)) { List <Thing> thingList = intVec.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { IThoughtGiver thoughtGiver = thingList[i] as IThoughtGiver; if (thoughtGiver != null) { Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought(); if (thought_Memory != null && thought_Memory.def == ThoughtDefOf.ObservedLayingCorpse) { if (!pawn.story.traits.HasTrait(TraitDefOfPsychology.BleedingHeart) && !pawn.story.traits.HasTrait(TraitDefOf.Psychopath) && !pawn.story.traits.HasTrait(TraitDefOf.Bloodlust) && !pawn.story.traits.HasTrait(TraitDefOfPsychology.Desensitized)) { if (((pawn.GetHashCode() ^ (GenLocalDate.DayOfYear(pawn) + GenLocalDate.Year(pawn) + (int)(GenLocalDate.DayPercent(pawn) * 5) * 60) * 391) % 1000) == 0) { pawn.story.traits.GainTrait(new Trait(TraitDefOfPsychology.Desensitized)); pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.RecentlyDesensitized, null); } } } } } } } } num++; } }
public static void ObserveSurroundingThingsPostfix(PawnObserver __instance) { Traverse traverse = Traverse.Create(__instance); Pawn pawn = (Pawn)AvP_PawnObserver_ObserveSurroundingThings_Patch.pawn.GetValue(__instance); // Log.Message(string.Format("ObserveSurroundingThingsPostfix {0}", pawn.LabelShortCap)); if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight) || pawn.isBloodMarked() || pawn.def == YautjaDefOf.RRY_Alien_Yautja) { // Log.Message("Blind"); return; } float num = pawn.health.capacities.GetLevel(PawnCapacityDefOf.Sight); // Log.Message(string.Format("Sight: {0}", num)); Map map = pawn.Map; // List<Thing> thingList = intVec.GetThingList(map).FindAll(x => x.def.thingClass == typeof(Pawn) && (Pawn)x != pawn); List <Pawn> thingList = map.mapPawns.AllPawns.Where(x => x != pawn && x.isXenomorph() && GenSight.LineOfSight(x.Position, pawn.Position, map, true, null, 0, 0) && pawn.Position.DistanceTo(x.Position) <= (20 * num)).ToList(); if (!thingList.NullOrEmpty()) { for (int i = 0; i < thingList.Count; i++) { Pawn observed = (Pawn)thingList[i]; if (observed == null) { return; } if (!observed.isXenomorph(out Comp_Xenomorph thoughtGiver)) { return; } // Log.Message(string.Format("{0} observed {1}", pawn.LabelShortCap, observed.LabelShortCap)); if (thoughtGiver != null) { Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought(); if (thought_Memory != null) { //Log.Message(string.Format("{0} TryGainMemory {1}", pawn.LabelShortCap, thought_Memory.LabelCap)); pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, observed); } // else Log.Message("thought_Memory == null"); } // else Log.Message(string.Format("thoughtGiver {0} == null", thingList[i].LabelShortCap)); } } // else Log.Message("thingList.NullOrEmpty"); }
public static void ObserveSurroundingThingsPostfix(PawnObserver __instance) { Traverse traverse = Traverse.Create(__instance); Pawn pawn = (Pawn)AvP_PawnObserver_ObserveSurroundingThings_Patch.pawn.GetValue(__instance); if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight)) { return; } Map map = pawn.Map; int num = 0; while ((float)num < 100f) { IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num]; if (intVec.InBounds(map)) { if (GenSight.LineOfSight(intVec, pawn.Position, map, true, null, 0, 0)) { List <Thing> thingList = intVec.GetThingList(map).FindAll(x => x.TryGetComp <Comp_Xenomorph>() != null); for (int i = 0; i < thingList.Count; i++) { IThoughtGiver thoughtGiver = thingList[i].TryGetComp <Comp_Xenomorph>() as IThoughtGiver; if (thoughtGiver != null) { Thought_Memory thought_Memory = thoughtGiver.GiveObservedThought(); if (thought_Memory != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(thought_Memory, null); } } } } } num++; } }
public void HitPawn(PawnObserver pawn) { if (pawn == null) { return; } var state = GetState(pawn); if (Time.realtimeSinceStartup - state.PawnLastHit < HIT_COOLDOWN_F) { return; } var direction = ReferenceEquals(pawn, LocalAsset) ? 1 : -1; state.UpdateHealth(UPDATE_DELTA_I * direction); var data = _pawns.Cast <KeyValuePair <PawnObserver, PawnState> >().ToDictionary(_ => _.Value.Player.ID, _ => _.Value.Health); _appController.GetComponent <PhotonView>().RPC("UpdateHealth", PhotonTargets.Others, data); Debug.Log("<color=blue>HitPawn LOCAL</color>"); }
public void SetPawn(PhotonPlayer player, PawnObserver pawn, UIHealthBarController healthBar) { _pawns[pawn] = new PawnState(player, healthBar); }
public PawnState GetState(PawnObserver pawn) { return(pawn != null && _pawns.ContainsKey(pawn) ? _pawns[pawn] : null); }