private void OnReachableChanged(object data) { KAnimControllerBase component = GetComponent <KAnimControllerBase>(); if ((bool)data) { GetComponent <KSelectable>().RemoveStatusItem(Db.Get().BuildingStatusItems.ConstructionUnreachable, false); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { KAnimControllerBase kAnimControllerBase = component; Game.LocationColours build = Game.Instance.uiColours.Build; kAnimControllerBase.TintColour = build.validLocation; } } else { GetComponent <KSelectable>().AddStatusItem(Db.Get().BuildingStatusItems.ConstructionUnreachable, this); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { KAnimControllerBase kAnimControllerBase2 = component; Game.LocationColours build2 = Game.Instance.uiColours.Build; kAnimControllerBase2.TintColour = build2.unreachable; } } }
public void Sync(KAnimControllerBase controller) { if (!((Object)masterController == (Object)null) && !((Object)controller == (Object)null)) { KAnim.Anim currentAnim = masterController.GetCurrentAnim(); if (currentAnim != null) { KAnim.PlayMode mode = masterController.GetMode(); float playSpeed = masterController.GetPlaySpeed(); float elapsedTime = masterController.GetElapsedTime(); controller.Play(currentAnim.name, mode, playSpeed, elapsedTime); Facing component = controller.GetComponent <Facing>(); if ((Object)component != (Object)null) { Vector3 position = component.transform.GetPosition(); float x = position.x; x += ((!masterController.FlipX) ? 0.5f : (-0.5f)); component.Face(x); } else { controller.FlipX = masterController.FlipX; controller.FlipY = masterController.FlipY; } } } }
public void PlayIdle(Instance smi) { KAnimControllerBase component = smi.GetComponent <KAnimControllerBase>(); Navigator component2 = smi.GetComponent <Navigator>(); NavType nav_type = component2.CurrentNavType; Facing component3 = smi.GetComponent <Facing>(); if (component3.GetFacing()) { nav_type = NavGrid.MirrorNavType(nav_type); } if (smi.def.customIdleAnim != null) { HashedString pre_anim = HashedString.Invalid; HashedString hashedString = smi.def.customIdleAnim(smi, ref pre_anim); if (hashedString != HashedString.Invalid) { if (pre_anim != HashedString.Invalid) { component.Play(pre_anim, KAnim.PlayMode.Once, 1f, 0f); } component.Queue(hashedString, KAnim.PlayMode.Loop, 1f, 0f); return; } } HashedString idleAnim = component2.NavGrid.GetIdleAnim(nav_type); component.Play(idleAnim, KAnim.PlayMode.Loop, 1f, 0f); }
protected override void OnSpawn() { base.OnSpawn(); if (conduit == null && bridge == null) { Debug.LogError($"[Pressurized] Pressurized component should not be added unless there is an accomponying Conduit or ConduitBridge component."); } if (!_loadedInfo) { _loadedInfo = true; string id = building.Def.PrefabID; IsBridge = bridge != null; Info = PressurizedTuning.GetPressurizedInfo(id); } if (!Info.IsDefault) { KAnimControllerBase kAnim = this.GetComponent <KAnimControllerBase>(); if (kAnim != null) { kAnim.TintColour = Info.KAnimTint; } else { Debug.LogWarning($"[Pressurized] Conduit.OnSpawn() KAnimControllerBase component was null!"); } } }
private void Initialize(KAnimControllerBase master, Grid.SceneLayer layer) { KBatchedAnimController effect = CreateEffect(master, layer); master.SetSymbolVisiblity("back", false); new KAnimLink(masterAnim, effect); }
private static void ApplyColorToBuilding(BuildingComplete building) { if (building.name.ToString().StartsWith("BigLiquidStorage") || building.name.ToString().StartsWith("BigGasReservoir")) { KAnimControllerBase kanim = building.GetComponent <KAnimControllerBase>(); if (kanim != null) { kanim.TintColour = defaultColor; CaiLib.Logger.Logger.Log(string.Concat("Updating Object Color:", building.name.ToString())); } } if (building.name.ToString().StartsWith("BigSolidStorage") || building.name.ToString().StartsWith("BigBeautifulStorage")) { TreeFilterable treeFilterable = building.GetComponent <TreeFilterable>(); if (treeFilterable != null) { Traverse traverse = Traverse.Create(treeFilterable); if (building.name.ToString().StartsWith("BigSolidStorage")) { traverse.Field("filterTint").SetValue(defaultColor); } if (building.name.ToString().StartsWith("BigBeautifulStorage")) { traverse.Field("filterTint").SetValue(beautifulColor); } Tag[] array = traverse.Field <List <Tag> >("acceptedTags").Value.ToArray(); treeFilterable.OnFilterChanged(array); } } }
private void AddBGGantry() { KAnimControllerBase component = GetComponent <KAnimControllerBase>(); GameObject gameObject = new GameObject(); gameObject.name = string.Format(rocket_module_bg_base_string, base.name, rocket_module_bg_affix); gameObject.SetActive(false); Vector3 position = component.transform.GetPosition(); position.z = Grid.GetLayerZ(Grid.SceneLayer.InteriorWall); gameObject.transform.SetPosition(position); gameObject.transform.parent = base.transform; KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.AnimFiles = new KAnimFile[1] { bgAnimFile }; kBatchedAnimController.initialAnim = rocket_module_bg_anim; kBatchedAnimController.fgLayer = Grid.SceneLayer.NoLayer; kBatchedAnimController.initialMode = KAnim.PlayMode.Paused; kBatchedAnimController.FlipX = component.FlipX; kBatchedAnimController.FlipY = component.FlipY; gameObject.SetActive(true); }
public static void Postfix(KMonoBehaviour ___root, Tag[] tags) { if (!IsActive(tags)) { return; } try{ KAnimControllerBase kanim = ___root.GetComponent <KAnimControllerBase>(); if (kanim != null) { if (___root.name.ToString().StartsWith("BigSolidStorage")) { kanim.TintColour = defaultColor; CaiLib.Logger.Logger.Log(string.Concat("Updating Filterable Object Color:", ___root.name.ToString())); } if (___root.name.ToString().StartsWith("BigBeautifulStorage")) { kanim.TintColour = beautifulColor; CaiLib.Logger.Logger.Log(string.Concat("Updating Filterable Object Color:", ___root.name.ToString())); } } } catch (Exception ex) { CaiLib.Logger.Logger.Log(ex.ToString()); } }
public void Sync() { for (int i = 0; i < Targets.Count; i++) { KAnimControllerBase controller = Targets[i]; Sync(controller); } }
public void PlayPost() { KAnimControllerBase kAnimControllerBase = base.sm.worker.Get <KAnimControllerBase>(base.smi); if (kAnimControllerBase.currentAnim != anims[2]) { base.sm.worker.Get <KAnimControllerBase>(base.smi).Play(anims[2], KAnim.PlayMode.Once, 1f, 0f); } }
public void PlayLoop() { KAnimControllerBase kAnimControllerBase = base.sm.worker.Get <KAnimControllerBase>(base.smi); if (kAnimControllerBase.currentAnim != anims[1]) { base.sm.worker.Get <KAnimControllerBase>(base.smi).Play(anims[1], KAnim.PlayMode.Loop, 1f, 0f); } }
public void Refresh(AmountInstance value_src) { GameObject gameObject = value_src.gameObject; if (!((Object)gameObject == (Object)null)) { KAnimControllerBase component = gameObject.GetComponent <KAnimControllerBase>(); Vector3 a = (!((Object)component != (Object)null)) ? (gameObject.transform.GetPosition() + Vector3.down) : component.GetWorldPivot(); base.transform.SetPosition(a + offset); if (value_src != null) { progressFill.transform.parent.gameObject.SetActive(true); float num = value_src.value / value_src.GetMax(); Vector3 localScale = progressFill.rectTransform.localScale; localScale.y = num; progressFill.rectTransform.localScale = localScale; progressToolTip.toolTip = DUPLICANTS.ATTRIBUTES.IMMUNITY.NAME + " " + GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None); } else { progressFill.transform.parent.gameObject.SetActive(false); } int num2 = 0; Amounts amounts = gameObject.GetComponent <Modifiers>().GetAmounts(); foreach (Disease resource in Db.Get().Diseases.resources) { float value = amounts.Get(resource.amount).value; if (value > 0f) { Image image = null; if (num2 < displayedDiseases.Count) { image = displayedDiseases[num2]; } else { GameObject gameObject2 = Util.KInstantiateUI(germsImage.gameObject, germsImage.transform.parent.gameObject, true); image = gameObject2.GetComponent <Image>(); displayedDiseases.Add(image); } image.color = resource.overlayColour; ToolTip component2 = image.GetComponent <ToolTip>(); component2.toolTip = resource.Name + " " + GameUtil.GetFormattedDiseaseAmount((int)value); num2++; } } for (int num3 = displayedDiseases.Count - 1; num3 >= num2; num3--) { Util.KDestroyGameObject(displayedDiseases[num3].gameObject); displayedDiseases.RemoveAt(num3); } diseasedImage.enabled = false; progressFill.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0); germsImage.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0); } }
public void SyncTime() { float elapsedTime = masterController.GetElapsedTime(); for (int i = 0; i < Targets.Count; i++) { KAnimControllerBase kAnimControllerBase = Targets[i]; kAnimControllerBase.SetElapsedTime(elapsedTime); } }
private KBatchedAnimController CreateEffect(KAnimControllerBase master, Grid.SceneLayer layer) { var effect = FXHelpers.CreateEffect(master.AnimFiles[0].name, transform.position, transform); effect.destroyOnAnimComplete = false; effect.SetSceneLayer(layer); effect.SetFGLayer(layer); effect.Play("backwall", KAnim.PlayMode.Paused); return(effect); }
public static void FlipAnim(KAnimControllerBase anim, Vector3 heading) { if (heading.x < 0f) { anim.FlipX = true; } else if (heading.x > 0f) { anim.FlipX = false; } }
protected override void OnStopWork(Worker worker) { base.OnStopWork(worker); if (session != null) { session.Cleanup(); session = null; } KAnimControllerBase component = GetComponent <KAnimControllerBase>(); component.Play("on", KAnim.PlayMode.Once, 1f, 0f); }
private void AddAnimTracker(GameObject go) { KAnimControllerBase component = go.GetComponent <KAnimControllerBase>(); if (!((Object)component == (Object)null) && component.AnimFiles != null && component.AnimFiles.Length > 0 && (Object)component.AnimFiles[0] != (Object)null && component.GetComponent <Pickupable>().trackOnPickup) { KBatchedAnimTracker kBatchedAnimTracker = go.AddComponent <KBatchedAnimTracker>(); kBatchedAnimTracker.useTargetPoint = false; kBatchedAnimTracker.fadeOut = false; kBatchedAnimTracker.symbol = new HashedString("snapTo_chest"); kBatchedAnimTracker.forceAlwaysVisible = true; } }
private Vector3 GetFollowPos() { if ((UnityEngine.Object)followTarget != (UnityEngine.Object)null) { Vector3 result = followTarget.transform.GetPosition(); KAnimControllerBase component = followTarget.GetComponent <KAnimControllerBase>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { result = component.GetWorldPivot(); } return(result); } return(Vector3.zero); }
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 static void Postfix(KMonoBehaviour ___root, Tag[] tags) { Color color = ColorHelper.GetComponentMaterialColor(___root); bool active = tags != null && tags.Length != 0; if (active) { KAnimControllerBase animBase = ___root.GetComponent <KAnimControllerBase>(); if (animBase != null) { animBase.TintColour = color; } } }
private void Register() { master.OnOverlayColourChanged += OnOverlayColourChanged; KAnimControllerBase kAnimControllerBase = master; kAnimControllerBase.OnTintChanged = (Action <Color>)Delegate.Combine(kAnimControllerBase.OnTintChanged, new Action <Color>(OnTintColourChanged)); KAnimControllerBase kAnimControllerBase2 = master; kAnimControllerBase2.OnHighlightChanged = (Action <Color>)Delegate.Combine(kAnimControllerBase2.OnHighlightChanged, new Action <Color>(OnHighlightColourChanged)); KAnimControllerBase kAnimControllerBase3 = master; KAnimControllerBase kAnimControllerBase4 = slave; kAnimControllerBase3.onLayerChanged += kAnimControllerBase4.SetLayer; }
public static void Postfix(BuildingComplete __instance) { KAnimControllerBase kAnimBase = __instance.GetComponent<KAnimControllerBase>(); if (kAnimBase != null) { if (__instance.name == "PollutedElectrolyzerComplete") // I found it in the logs { float r = 255 - 70;// 100 float g = 255; // more the int after - is big, less green and more pink float b = 255 - 150; //50 kAnimBase.TintColour = new Color(r / 255f, g / 255f, b / 255f); } } }
public static void Postfix(Ownable __instance) { Color color = ColorHelper.GetComponentMaterialColor(__instance); bool owned = __instance.assignee != null; if (owned) { KAnimControllerBase animBase = __instance.GetComponent <KAnimControllerBase>(); if (animBase != null) { animBase.TintColour = color; } } }
public void ClearOverlayColour() { Color32 c = Color.black; for (int i = 0; i < data.Count; i++) { InfraredVisualizerData infraredVisualizerData = data[i]; KAnimControllerBase controller = infraredVisualizerData.controller; if ((Object)controller != (Object)null) { controller.OverlayColour = c; } } }
private void SetVisible(bool visible) { KAnimControllerBase component = base.gameObject.GetComponent <KAnimControllerBase>(); if ((Object)component != (Object)null && component.enabled != visible) { component.enabled = visible; } KSelectable component2 = base.gameObject.GetComponent <KSelectable>(); if ((Object)component2 != (Object)null && component2.enabled != visible) { component2.enabled = visible; } }
private void RefreshDepthAvailable() { int num = PumpingStationGuide.GetDepthAvailable(Grid.PosToCell(this), base.gameObject); int num2 = 4; if (num > depthAvailable) { KAnimControllerBase component = GetComponent <KAnimControllerBase>(); for (int i = 1; i <= num2; i++) { component.SetSymbolVisiblity("pipe" + i.ToString(), i <= num); } PumpingStationGuide.OccupyArea(base.gameObject, num); depthAvailable = num; } }
public void Unregister() { if ((UnityEngine.Object)master != (UnityEngine.Object)null) { master.OnOverlayColourChanged -= OnOverlayColourChanged; KAnimControllerBase kAnimControllerBase = master; kAnimControllerBase.OnTintChanged = (Action <Color>)Delegate.Remove(kAnimControllerBase.OnTintChanged, new Action <Color>(OnTintColourChanged)); KAnimControllerBase kAnimControllerBase2 = master; kAnimControllerBase2.OnHighlightChanged = (Action <Color>)Delegate.Remove(kAnimControllerBase2.OnHighlightChanged, new Action <Color>(OnHighlightColourChanged)); if ((UnityEngine.Object)slave != (UnityEngine.Object)null) { KAnimControllerBase kAnimControllerBase3 = master; KAnimControllerBase kAnimControllerBase4 = slave; kAnimControllerBase3.onLayerChanged -= kAnimControllerBase4.SetLayer; } } }
private void UpdateTint() { KAnimControllerBase component = GetComponent <KAnimControllerBase>(); if ((Object)component != (Object)null && component.HasBatchInstanceData) { component.TintColour = ((assignee != null) ? ownedTint : unownedTint); } else { KBatchedAnimController component2 = GetComponent <KBatchedAnimController>(); if ((Object)component2 != (Object)null && component2.HasBatchInstanceData) { component2.TintColour = ((assignee != null) ? ownedTint : unownedTint); } } }
public static void ApplyColorToKAnimControllerBase(Component component) { KAnimControllerBase animBase = component.GetComponent <KAnimControllerBase>(); if (animBase != null) { Color color = ColorHelper.GetComponentMaterialColor(component); Painter.Filter(animBase.name, ref color); animBase.TintColour = color; } else { State.Common.Logger.LogOnce("Failed to find KAnimControllerBase", component.name); } }
public VariantController( KAnimControllerBase controllerBase, string variantTarget, string variantAnimation, int totalVariants, Grid.SceneLayer renderLayer ) { this.totalVariants = totalVariants; string name = $"{controllerBase.name}.{variantAnimation}"; gameObject = UnityEngine.Object.Instantiate <GameObject>(Assets.GetPrefab(MeterConfig.ID)); gameObject.name = name; gameObject.SetActive(false); gameObject.transform.parent = controllerBase.transform; gameObject.GetComponent <KPrefabID>().PrefabTag = new Tag(name); var position = controllerBase.transform.GetPosition(); position.z = Grid.GetLayerZ(renderLayer); gameObject.transform.SetPosition(position); variantController = gameObject.GetComponent <KBatchedAnimController>(); variantController.AnimFiles = new KAnimFile[] { controllerBase.AnimFiles[0] }; variantController.initialAnim = variantAnimation; variantController.fgLayer = Grid.SceneLayer.NoLayer; variantController.initialMode = KAnim.PlayMode.Paused; variantController.isMovable = true; variantController.FlipX = controllerBase.FlipX; variantController.FlipY = controllerBase.FlipY; variantController.sceneLayer = renderLayer; variantTracker = gameObject.GetComponent <KBatchedAnimTracker>(); // variantTracker.offset = offset; variantTracker.symbol = variantTarget; gameObject.SetActive(true); controllerBase.SetSymbolVisiblity(variantTarget, false); variantLink = new KAnimLink(controllerBase, variantController); }