public static void AddHat(string hat_id, KBatchedAnimController controller) { AccessorySlot hat = Db.Get().AccessorySlots.Hat; Accessory accessory = hat.Lookup(hat_id); if (accessory == null) { Debug.LogWarning("Missing hat: " + hat_id); } Accessorizer component = controller.GetComponent <Accessorizer>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { Accessory accessory2 = component.GetAccessory(Db.Get().AccessorySlots.Hat); if (accessory2 != null) { component.RemoveAccessory(accessory2); } if (accessory != null) { component.AddAccessory(accessory); } } else { SymbolOverrideController component2 = controller.GetComponent <SymbolOverrideController>(); component2.TryRemoveSymbolOverride(hat.targetSymbolId, 4); component2.AddSymbolOverride(hat.targetSymbolId, accessory.symbol, 4); } controller.SetSymbolVisiblity(hat.targetSymbolId, true); controller.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, true); controller.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, false); }
internal static void Postfix(KBatchedAnimController controller) { Pressurized pressure = controller.GetComponent <Pressurized>(); if (!Pressurized.IsDefault(pressure)) { controller.TintColour = pressure.Info.KAnimTint; } else { controller.GetComponent <Tintable>()?.SetTint(); } }
public static void RemoveHat(KBatchedAnimController controller) { AccessorySlot hat = Db.Get().AccessorySlots.Hat; Accessorizer component = controller.GetComponent <Accessorizer>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { Accessory accessory = component.GetAccessory(hat); if (accessory != null) { component.RemoveAccessory(accessory); } } else { controller.GetComponent <SymbolOverrideController>().TryRemoveSymbolOverride(hat.targetSymbolId, 4); } controller.SetSymbolVisiblity(hat.targetSymbolId, false); controller.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, false); controller.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, true); }
public MeterController(KAnimControllerBase building_controller, KBatchedAnimController meter_controller, params string[] symbol_names) { if (!((UnityEngine.Object)meter_controller == (UnityEngine.Object)null)) { meterController = meter_controller; link = new KAnimLink(building_controller, meter_controller); for (int i = 0; i < symbol_names.Length; i++) { building_controller.SetSymbolVisiblity(symbol_names[i], false); } KBatchedAnimTracker component = meterController.GetComponent <KBatchedAnimTracker>(); component.symbol = new HashedString(symbol_names[0]); } }
public void RefreshStorage() { if (!refreshingStorage) { refreshingStorage = true; float num = 0f; foreach (GameObject item in botStorage.items) { if (!((Object)item == (Object)null)) { num += item.GetComponent <PrimaryElement>().Mass; int cell = Grid.PosToCell(smi.transform.GetPosition()); int cell2 = Grid.CellBelow(Grid.CellBelow(cell)); item.transform.SetPosition(Grid.CellToPosCBC(cell2, Grid.SceneLayer.BuildingBack)); } } if (num == 0f) { float num2 = 0f; foreach (GameObject item2 in topStorage.items) { if (!((Object)item2 == (Object)null)) { num2 += item2.GetComponent <PrimaryElement>().Mass; } } if (num2 > 0f) { anim.SetSymbolVisiblity(HASH_FEEDBALL, true); anim.Play("ball", KAnim.PlayMode.Once, 1f, 0f); Pickupable pickupable = topStorage.items[0].GetComponent <Pickupable>().Take(massPerBall); KAnim.Build.Symbol symbol = pickupable.GetComponent <KBatchedAnimController>().AnimFiles[0].GetData().build.GetSymbol("algae"); if (symbol != null) { anim.GetComponent <SymbolOverrideController>().AddSymbolOverride(HASH_FEEDBALL, symbol, 0); } botStorage.Store(pickupable.gameObject, false, false, true, false); int cell3 = Grid.PosToCell(smi.transform.GetPosition()); int cell4 = Grid.CellBelow(Grid.CellBelow(cell3)); pickupable.transform.SetPosition(Grid.CellToPosCBC(cell4, Grid.SceneLayer.BuildingUse)); } else { anim.SetSymbolVisiblity(HASH_FEEDBALL, false); } } refreshingStorage = false; } }
protected override void OnActivateTool() { lastDragCell = -1; if ((Object)visualizer != (Object)null) { ClearTilePreview(); Object.Destroy(visualizer); } active = true; base.OnActivateTool(); buildingOrientation = Orientation.Neutral; placementPivot = def.placementPivot; Vector3 cursorPos = PlayerController.GetCursorPos(KInputManager.GetMousePos()); GameObject buildingPreview = def.BuildingPreview; Vector3 position = cursorPos; Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore; int gameLayer = LayerMask.NameToLayer("Place"); visualizer = GameUtil.KInstantiate(buildingPreview, position, sceneLayer, null, gameLayer); KBatchedAnimController component = visualizer.GetComponent <KBatchedAnimController>(); if ((Object)component != (Object)null) { component.visibilityType = KAnimControllerBase.VisibilityType.Always; component.isMovable = true; component.Offset = def.GetVisualizerOffset(); component.Offset += def.placementPivot; component.name = component.GetComponent <KPrefabID>().GetDebugName() + "_visualizer"; } visualizer.SetActive(true); UpdateVis(cursorPos); BuildToolHoverTextCard component2 = GetComponent <BuildToolHoverTextCard>(); component2.currentDef = def; ResourceRemainingDisplayScreen.instance.ActivateDisplay(visualizer); if ((Object)component == (Object)null) { visualizer.SetLayerRecursively(LayerMask.NameToLayer("Place")); } else { component.SetLayer(LayerMask.NameToLayer("Place")); } GridCompositor.Instance.ToggleMajor(true); }
private void ShowHelmet() { KBatchedAnimController assigneeController = GetAssigneeController(); if (!((Object)assigneeController == (Object)null)) { KAnimHashedString kAnimHashedString = new KAnimHashedString("snapTo_neck"); if (!string.IsNullOrEmpty(anim_file)) { KAnimFile anim = Assets.GetAnim(anim_file); assigneeController.GetComponent <SymbolOverrideController>().AddSymbolOverride(kAnimHashedString, anim.GetData().build.GetSymbol(kAnimHashedString), 6); } assigneeController.SetSymbolVisiblity(kAnimHashedString, true); is_shown = true; UpdateJets(); } }
private void HideHelmet() { is_shown = false; KBatchedAnimController assigneeController = GetAssigneeController(); if (!((Object)assigneeController == (Object)null)) { KAnimHashedString kAnimHashedString = "snapTo_neck"; if (!string.IsNullOrEmpty(anim_file)) { SymbolOverrideController component = assigneeController.GetComponent <SymbolOverrideController>(); if ((Object)component == (Object)null) { return; } component.RemoveSymbolOverride(kAnimHashedString, 6); } assigneeController.SetSymbolVisiblity(kAnimHashedString, false); UpdateJets(); } }
public static KBatchedAnimController CreateEffect(string anim_file_name, Vector3 position, Transform parent = null, bool update_looping_sounds_position = false, Grid.SceneLayer layer = Grid.SceneLayer.Front, bool set_inactive = false) { KBatchedAnimController component = GameUtil.KInstantiate(Assets.GetPrefab(EffectConfigs.EffectTemplateId), position, layer, null, 0).GetComponent <KBatchedAnimController>(); KPrefabID component2 = component.GetComponent <KPrefabID>(); component2.PrefabTag = TagManager.Create(anim_file_name); component.name = anim_file_name; if ((Object)parent != (Object)null) { component.transform.SetParent(parent, false); } component.transform.SetPosition(position); if (update_looping_sounds_position) { LoopingSounds loopingSounds = component.FindOrAddComponent <LoopingSounds>(); loopingSounds.updatePosition = true; } KAnimFile anim = Assets.GetAnim(anim_file_name); if ((Object)anim == (Object)null) { Debug.LogWarning("Missing effect anim: " + anim_file_name); } else { component.AnimFiles = new KAnimFile[1] { anim }; } if (!set_inactive) { component.gameObject.SetActive(true); } return(component); }
public static void SetPortraitData(IAssignableIdentity identityObject, KBatchedAnimController controller, bool useDefaultExpression = true) { if (identityObject == null) { controller.gameObject.SetActive(false); } else { MinionIdentity minionIdentity = identityObject as MinionIdentity; if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null) { MinionAssignablesProxy minionAssignablesProxy = identityObject as MinionAssignablesProxy; if ((UnityEngine.Object)minionAssignablesProxy != (UnityEngine.Object)null && minionAssignablesProxy.target != null) { minionIdentity = (minionAssignablesProxy.target as MinionIdentity); } } controller.gameObject.SetActive(true); controller.Play("ui_idle", KAnim.PlayMode.Once, 1f, 0f); SymbolOverrideController component = controller.GetComponent <SymbolOverrideController>(); component.RemoveAllSymbolOverrides(0); if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { Accessorizer component2 = minionIdentity.GetComponent <Accessorizer>(); foreach (AccessorySlot resource in Db.Get().AccessorySlots.resources) { Accessory accessory = component2.GetAccessory(resource); if (accessory != null) { component.AddSymbolOverride(resource.targetSymbolId, accessory.symbol, 0); controller.SetSymbolVisiblity(resource.targetSymbolId, true); } } component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(component2.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1); RefreshHat(minionIdentity, controller); } else { StoredMinionIdentity storedMinionIdentity = identityObject as StoredMinionIdentity; if ((UnityEngine.Object)storedMinionIdentity == (UnityEngine.Object)null) { MinionAssignablesProxy minionAssignablesProxy2 = identityObject as MinionAssignablesProxy; if ((UnityEngine.Object)minionAssignablesProxy2 != (UnityEngine.Object)null && minionAssignablesProxy2.target != null) { storedMinionIdentity = (minionAssignablesProxy2.target as StoredMinionIdentity); } } if (!((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null)) { controller.gameObject.SetActive(false); return; } foreach (AccessorySlot resource2 in Db.Get().AccessorySlots.resources) { Accessory accessory2 = storedMinionIdentity.GetAccessory(resource2); if (accessory2 != null) { component.AddSymbolOverride(resource2.targetSymbolId, accessory2.symbol, 0); controller.SetSymbolVisiblity(resource2.targetSymbolId, true); } } component.AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol, 1); RefreshHat(storedMinionIdentity, controller); } float animScale = 1f; if ((UnityEngine.Object)GameScreenManager.Instance != (UnityEngine.Object)null && (UnityEngine.Object)GameScreenManager.Instance.ssOverlayCanvas != (UnityEngine.Object)null) { animScale = 0.2f * (1f / GameScreenManager.Instance.ssOverlayCanvas.GetComponent <KCanvasScaler>().GetUserScale()); } controller.animScale = animScale; string s = "ui"; controller.Play(s, KAnim.PlayMode.Loop, 1f, 0f); controller.SetSymbolVisiblity("snapTo_neck", false); controller.SetSymbolVisiblity("snapTo_goggles", false); } }
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); } }
private void SetPortraitAnimator(IAssignableIdentity identity) { if (identity != null && !identity.IsNull()) { if ((UnityEngine.Object)animController == (UnityEngine.Object)null) { animController = Util.KInstantiateUI(Assets.GetPrefab(new Tag("FullMinionUIPortrait")), duplicantAnimAnchor.gameObject, false).GetComponent <KBatchedAnimController>(); animController.gameObject.SetActive(true); KCanvasScaler kCanvasScaler = UnityEngine.Object.FindObjectOfType <KCanvasScaler>(); animController.animScale = baseCharacterScale * (1f / kCanvasScaler.GetCanvasScale()); ScreenResize instance = ScreenResize.Instance; instance.OnResize = (System.Action)Delegate.Combine(instance.OnResize, new System.Action(OnResize)); } string value = string.Empty; Accessorizer component = animController.GetComponent <Accessorizer>(); for (int num = component.GetAccessories().Count - 1; num >= 0; num--) { component.RemoveAccessory(component.GetAccessories()[num].Get()); } MinionIdentity minionIdentity = identity as MinionIdentity; StoredMinionIdentity storedMinionIdentity = identity as StoredMinionIdentity; Accessorizer accessorizer = null; if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { accessorizer = minionIdentity.GetComponent <Accessorizer>(); foreach (ResourceRef <Accessory> accessory in accessorizer.GetAccessories()) { component.AddAccessory(accessory.Get()); } value = minionIdentity.GetComponent <MinionResume>().CurrentHat; } else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null) { foreach (ResourceRef <Accessory> accessory2 in storedMinionIdentity.accessories) { component.AddAccessory(accessory2.Get()); } value = storedMinionIdentity.currentHat; } HashedString name = "anim_idle_healthy_kanim"; idle_anim = Assets.GetAnim(name); if ((UnityEngine.Object)idle_anim != (UnityEngine.Object)null) { animController.AddAnimOverrides(idle_anim, 0f); } animController.Queue("idle_default", KAnim.PlayMode.Loop, 1f, 0f); AccessorySlot hat = Db.Get().AccessorySlots.Hat; animController.SetSymbolVisiblity(hat.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false); animController.SetSymbolVisiblity(Db.Get().AccessorySlots.Hair.targetSymbolId, string.IsNullOrEmpty(value) ? true : false); animController.SetSymbolVisiblity(Db.Get().AccessorySlots.HatHair.targetSymbolId, (!string.IsNullOrEmpty(value)) ? true : false); KAnim.Build.Symbol source_symbol = null; KAnim.Build.Symbol source_symbol2 = null; if ((bool)accessorizer) { source_symbol = accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol; source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(accessorizer.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol; } else if ((UnityEngine.Object)storedMinionIdentity != (UnityEngine.Object)null) { source_symbol = storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol; source_symbol2 = Db.Get().AccessorySlots.HatHair.Lookup("hat_" + HashCache.Get().Get(storedMinionIdentity.GetAccessory(Db.Get().AccessorySlots.Hair).symbol.hash)).symbol; } animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HairAlways.targetSymbolId, source_symbol, 1); animController.GetComponent <SymbolOverrideController>().AddSymbolOverride(Db.Get().AccessorySlots.HatHair.targetSymbolId, source_symbol2, 1); } }