public void Equip(Equippable item, EquipSlots slots) { UnEquip(slots); _items.Add(item); item.transform.SetParent(transform); item.slots = slots; item.OnEquip(); this.PostNotification(EquippedNotification, item); }
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); }