public static void Postfix(EatChore.States __instance) { if (ModSettings.Instance.ShareTables) { __instance.eatatmessstation.Exit(delegate(EatChore.StatesInstance smi) { var minion = smi.sm.eater.Get(smi).GetComponent <MinionIdentity>(); if (minion == null) { return; } Ownables ownables = minion.GetSoleOwner(); if (ownables == null) { return; } AssignableSlotInstance slot = ownables.GetSlot(Db.Get().AssignableSlots.MessStation); if (slot == null) { return; } slot.Unassign(true); }); } }
public static void Postfix(SleepChore.States __instance) { if (ModSettings.Instance.ShareBeds) { __instance.success.Exit(delegate(SleepChore.StatesInstance smi) { var minion = smi.sm.sleeper.Get(smi).GetComponent <MinionIdentity>(); if (minion == null) { return; } Ownables ownables = minion.GetSoleOwner(); if (ownables == null) { return; } AssignableSlotInstance slot = ownables.GetSlot(Db.Get().AssignableSlots.Bed); if (slot == null) { return; } slot.Unassign(false); }); } }
public void OnEquip(AssignableSlotInstance slot) { isEquipped = true; if ((Object)SelectTool.Instance.selected == (Object)selectable) { SelectTool.Instance.Select(null, false); } GetComponent <KBatchedAnimController>().enabled = false; GetComponent <KSelectable>().IsSelectable = false; MinionAssignablesProxy component = slot.gameObject.GetComponent <MinionAssignablesProxy>(); GameObject targetGameObject = component.GetTargetGameObject(); Effects component2 = targetGameObject.GetComponent <Effects>(); if ((Object)component2 != (Object)null) { foreach (Effect effectImmunite in def.EffectImmunites) { component2.AddImmunity(effectImmunite); } } if (def.OnEquipCallBack != null) { def.OnEquipCallBack(this); } GetComponent <KPrefabID>().AddTag(GameTags.Equipped, false); }
public override void Assign(IAssignableIdentity new_assignee) { if (new_assignee != assignee) { if (base.slot != null && new_assignee is MinionIdentity) { new_assignee = (new_assignee as MinionIdentity).assignableProxy.Get(); } if (base.slot != null && new_assignee is StoredMinionIdentity) { new_assignee = (new_assignee as StoredMinionIdentity).assignableProxy.Get(); } if (new_assignee is MinionAssignablesProxy) { Ownables soleOwner = new_assignee.GetSoleOwner(); Ownables component = soleOwner.GetComponent <Ownables>(); AssignableSlotInstance slot = component.GetSlot(base.slot); if (slot != null) { Assignable assignable = slot.assignable; if ((Object)assignable != (Object)null) { assignable.Unassign(); } } } base.Assign(new_assignee); } }
public override void Update() { for (int i = 0; i < slots.Length; i++) { SlotEntry slotEntry = slots[i]; AssignableSlotInstance slot = slotEntry.slot; if (slot.IsAssigned()) { bool flag = slot.assignable.GetNavigationCost(navigator) != -1; Operational component = slot.assignable.GetComponent <Operational>(); if ((Object)component != (Object)null) { flag = (flag && component.IsOperational); } if (flag != slotEntry.isReachable) { slotEntry.isReachable = flag; slots[i] = slotEntry; Trigger(334784980, slotEntry); } } else if (slotEntry.isReachable) { slotEntry.isReachable = false; slots[i] = slotEntry; Trigger(334784980, slotEntry); } } }
public void FindAvailableMedicalBed(Navigator navigator) { Clinic clinic = null; AssignableSlot clinic2 = Db.Get().AssignableSlots.Clinic; Ownables soleOwner = gameObject.GetComponent <MinionIdentity>().GetSoleOwner(); AssignableSlotInstance slot = soleOwner.GetSlot(clinic2); if ((UnityEngine.Object)slot.assignable == (UnityEngine.Object)null) { Assignable assignable = soleOwner.AutoAssignSlot(clinic2); if ((UnityEngine.Object)assignable != (UnityEngine.Object)null) { clinic = assignable.GetComponent <Clinic>(); } } else { clinic = slot.assignable.GetComponent <Clinic>(); } if ((UnityEngine.Object)clinic != (UnityEngine.Object)null && navigator.CanReach(clinic)) { base.smi.sm.clinic.Set(clinic.gameObject, base.smi); base.smi.GoTo(base.smi.sm.incapacitation_root.rescue.waitingForPickup); } }
public static void UnassignClinic(WoundMonitor.Instance smi) { AssignableSlotInstance slot = smi.sm.masterTarget.Get(smi).GetComponent <Ownables>().GetSlot(Db.Get().AssignableSlots.Clinic); if (slot == null) { return; } slot.Unassign(true); }
public void AutoAssignClinic() { Ownables soleOwner = base.sm.masterTarget.Get(base.smi).GetComponent <MinionIdentity>().GetSoleOwner(); AssignableSlot clinic = Db.Get().AssignableSlots.Clinic; AssignableSlotInstance slot = soleOwner.GetSlot(clinic); if (slot != null && !((Object)slot.assignable != (Object)null)) { soleOwner.AutoAssignSlot(clinic); } }
public static void AutoAssignClinic(WoundMonitor.Instance smi) { Ownables component = smi.sm.masterTarget.Get(smi).GetComponent <Ownables>(); AssignableSlot clinic = Db.Get().AssignableSlots.Clinic; AssignableSlotInstance slot = component.GetSlot(clinic); if (slot == null || (Object)slot.assignable != (Object)null) { return; } component.AutoAssignSlot(clinic); }
public void Refresh(object data = null) { if (!sideScreen.targetAssignable.CanAssignTo(targetIdentity)) { currentState = AssignableState.Disabled; assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.DISABLED; } else if (sideScreen.targetAssignable.assignee == targetIdentity) { currentState = AssignableState.Selected; assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.ASSIGNED; } else { bool flag = false; KMonoBehaviour kMonoBehaviour = targetIdentity as KMonoBehaviour; if ((UnityEngine.Object)kMonoBehaviour != (UnityEngine.Object)null) { Ownables component = kMonoBehaviour.GetComponent <Ownables>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { AssignableSlotInstance slot = component.GetSlot(sideScreen.targetAssignable.slot); if (slot != null && slot.IsAssigned()) { currentState = AssignableState.AssignedToOther; assignmentText.text = slot.assignable.GetProperName(); flag = true; } } Equipment component2 = kMonoBehaviour.GetComponent <Equipment>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { AssignableSlotInstance slot2 = component2.GetSlot(sideScreen.targetAssignable.slot); if (slot2 != null && slot2.IsAssigned()) { currentState = AssignableState.AssignedToOther; assignmentText.text = slot2.assignable.GetProperName(); flag = true; } } } if (!flag) { currentState = AssignableState.Unassigned; assignmentText.text = UI.UISIDESCREENS.ASSIGNABLESIDESCREEN.UNASSIGNED; } } toggle.ChangeState((int)currentState); }
private string GetAssignedEffectsString(AssignableSlotInstance slot) { string empty = string.Empty; List <Descriptor> list = new List <Descriptor>(); list.AddRange(GameUtil.GetGameObjectEffects(slot.assignable.gameObject, false)); if (list.Count > 0) { empty += "\n"; { foreach (Descriptor item in list) { empty = empty + " • " + item.IndentedText() + "\n"; } return(empty); } } return(empty); }
public void Add(AssignableSlotInstance slot_instance) { slots.Add(slot_instance); }
public void Equip(Equippable equippable) { AssignableSlotInstance slot = GetSlot(equippable.slot); slot.Assign(equippable); GameObject targetGameObject = GetTargetGameObject(); Debug.Assert(targetGameObject, "GetTargetGameObject returned null in Equip"); targetGameObject.Trigger(-448952673, equippable.GetComponent <KPrefabID>()); equippable.Trigger(-1617557748, this); Attributes attributes = targetGameObject.GetAttributes(); if (attributes != null) { foreach (AttributeModifier attributeModifier in equippable.def.AttributeModifiers) { attributes.Add(attributeModifier); } } SnapOn component = targetGameObject.GetComponent <SnapOn>(); if ((Object)component != (Object)null) { component.AttachSnapOnByName(equippable.def.SnapOn); if (equippable.def.SnapOn1 != null) { component.AttachSnapOnByName(equippable.def.SnapOn1); } } KBatchedAnimController component2 = targetGameObject.GetComponent <KBatchedAnimController>(); if ((Object)component2 != (Object)null && (Object)equippable.def.BuildOverride != (Object)null) { component2.GetComponent <SymbolOverrideController>().AddBuildOverride(equippable.def.BuildOverride.GetData(), equippable.def.BuildOverridePriority); } if ((bool)equippable.transform.parent) { Storage component3 = equippable.transform.parent.GetComponent <Storage>(); if ((bool)component3) { component3.Drop(equippable.gameObject, true); } } equippable.transform.parent = slot.gameObject.transform; equippable.transform.SetLocalPosition(Vector3.zero); SetEquippableStoredModifiers(equippable, true); equippable.OnEquip(slot); if (refreshHandle.TimeRemaining > 0f) { Debug.LogWarning(targetGameObject.GetProperName() + " is already in the process of changing equipment (equip)"); refreshHandle.ClearScheduler(); } CreatureSimTemperatureTransfer transferer = targetGameObject.GetComponent <CreatureSimTemperatureTransfer>(); if (!((Object)component2 == (Object)null)) { refreshHandle = GameScheduler.Instance.Schedule("ChangeEquipment", 2f, delegate { if ((Object)transferer != (Object)null) { transferer.RefreshRegistration(); } }, null, null); } Game.Instance.Trigger(-2146166042, null); }
public void Unequip(Equippable equippable) { AssignableSlotInstance slot = GetSlot(equippable.slot); slot.Unassign(true); equippable.Trigger(-170173755, this); GameObject targetGameObject = GetTargetGameObject(); if ((bool)targetGameObject) { targetGameObject.Trigger(-1285462312, equippable.GetComponent <KPrefabID>()); KBatchedAnimController component = targetGameObject.GetComponent <KBatchedAnimController>(); if (!destroyed) { if ((Object)equippable.def.BuildOverride != (Object)null && (Object)component != (Object)null) { component.GetComponent <SymbolOverrideController>().TryRemoveBuildOverride(equippable.def.BuildOverride.GetData(), equippable.def.BuildOverridePriority); } Attributes attributes = targetGameObject.GetAttributes(); if (attributes != null) { foreach (AttributeModifier attributeModifier in equippable.def.AttributeModifiers) { attributes.Remove(attributeModifier); } } if (!equippable.def.IsBody) { SnapOn component2 = targetGameObject.GetComponent <SnapOn>(); component2.DetachSnapOnByName(equippable.def.SnapOn); if (equippable.def.SnapOn1 != null) { component2.DetachSnapOnByName(equippable.def.SnapOn1); } } if ((bool)equippable.transform.parent) { Storage component3 = equippable.transform.parent.GetComponent <Storage>(); if ((bool)component3) { component3.Drop(equippable.gameObject, true); } } SetEquippableStoredModifiers(equippable, false); equippable.transform.parent = null; equippable.transform.SetPosition(targetGameObject.transform.GetPosition() + Vector3.up / 2f); KBatchedAnimController component4 = equippable.GetComponent <KBatchedAnimController>(); if ((bool)component4) { component4.SetSceneLayer(Grid.SceneLayer.Ore); } if (!((Object)component == (Object)null)) { if (refreshHandle.TimeRemaining > 0f) { refreshHandle.ClearScheduler(); } refreshHandle = GameScheduler.Instance.Schedule("ChangeEquipment", 1f, delegate { GameObject gameObject = (!((Object)this != (Object)null)) ? null : GetTargetGameObject(); if ((bool)gameObject) { CreatureSimTemperatureTransfer component5 = gameObject.GetComponent <CreatureSimTemperatureTransfer>(); if ((Object)component5 != (Object)null) { component5.RefreshRegistration(); } } }, null, null); } } Game.Instance.Trigger(-2146166042, null); } }