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]); } }
protected override void OnSpawn() { base.OnSpawn(); // self position var position = transform.position; selfXY = Grid.PosToXY(position); selfCell = Grid.PosToCell(position); // range detector var anchorMinRotatedOffset = rotatable.GetRotatedCellOffset(new CellOffset(rangeX, rangeY)); var anchorMinRotated = Grid.CellToPos2D(Grid.OffsetCell(selfCell, anchorMinRotatedOffset)); var sizeRotatedOffset = rotatable.GetRotatedCellOffset(new CellOffset(rangeWidth - 1, rangeHeight - 1)); rangeRect = new Rect(anchorMinRotated, sizeRotatedOffset.ToVector3()); // anim _hitEffectPrefab = Assets.GetPrefab((Tag)EffectConfigs.AttackSplashId); var animCtrl = GetComponent <KBatchedAnimController>(); var armName = animCtrl.name + ".gun"; _armGo = new GameObject(armName); _armGo.SetActive(false); _armGo.transform.parent = animCtrl.transform; _loopingSounds = _armGo.AddComponent <LoopingSounds>(); rotateSound = GlobalAssets.GetSound(rotateSound); _armGo.AddComponent <KPrefabID>().PrefabTag = new Tag(armName); armAnimCtrl = _armGo.AddComponent <KBatchedAnimController>(); armAnimCtrl.AnimFiles = new[] { animCtrl.AnimFiles[0] }; armAnimCtrl.initialAnim = "gun"; armAnimCtrl.isMovable = true; armAnimCtrl.sceneLayer = Grid.SceneLayer.TransferArm; animCtrl.SetSymbolVisiblity((KAnimHashedString)"gun_target", false); Vector3 column = animCtrl.GetSymbolTransform(new HashedString("gun_target"), out _).GetColumn(3); column.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm); _armGo.transform.SetPosition(column); _armGo.SetActive(true); _link = new KAnimLink(animCtrl, armAnimCtrl); // events Subscribe((int)GameHashes.CopySettings, OnCopySettings); // init //RotateArm(0f, 0f); //ClearTarget(); smi.StartSM(); }
protected override void OnSpawn() { base.OnSpawn(); var animController = GetComponent <KBatchedAnimController>(); string armName = animController.name + ".arm"; arm = new GameObject(armName); arm.SetActive(false); arm.transform.parent = animController.transform; arm.AddComponent <KPrefabID>().PrefabTag = new Tag(armName); armAnimController = arm.AddComponent <KBatchedAnimController>(); armAnimController.AnimFiles = new KAnimFile[1] { animController.AnimFiles[0] }; armAnimController.initialAnim = "arm"; armAnimController.isMovable = true; armAnimController.sceneLayer = Grid.SceneLayer.TransferArm; animController.SetSymbolVisiblity(ARM_TARGET, false); var column = animController.GetSymbolTransform(ARM_TARGET, out var isVisible).GetColumn(3); column.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm); arm.transform.SetPosition(column); arm.SetActive(true); armAnimLink = new KAnimLink(animController, armAnimController); var choreGroups = Db.Get().ChoreGroups; for (int i = 0; i < choreGroups.Count; i++) { choreConsumer.SetPermittedByUser(choreGroups[i], true); } Subscribe((int)GameHashes.OperationalChanged, OnOperationalChangedDelegate); Subscribe((int)GameHashes.EndChore, OnEndChoreDelegate); // dunno why this is needed, but it is? animController.enabled = false; animController.enabled = true; MinionGroupProber.Get().SetValidSerialNos(this, serialNumber, serialNumber); smi.StartSM(); }
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); }
protected override void OnSpawn() { KBatchedAnimController component = this.GetComponent <KBatchedAnimController>(); component.TintColour = new Color(0.5f, 0.5f, 1.0f, 1.0f); string name = component.name + ".gun"; this.arm_go = new GameObject(name); this.arm_go.SetActive(value: false); this.arm_go.transform.parent = component.transform; this.looping_sounds = this.arm_go.AddComponent <LoopingSounds>(); this.rotateSound = GlobalAssets.GetSound(this.rotateSound); KPrefabID kPrefabID = this.arm_go.AddComponent <KPrefabID>(); kPrefabID.PrefabTag = new Tag(name); this.arm_anim_ctrl = this.arm_go.AddComponent <KBatchedAnimController>(); this.arm_anim_ctrl.AnimFiles = new KAnimFile[1] { component.AnimFiles[0] }; this.arm_anim_ctrl.initialAnim = "gun"; this.arm_anim_ctrl.isMovable = true; this.arm_anim_ctrl.sceneLayer = Grid.SceneLayer.TransferArm; this.arm_anim_ctrl.TintColour = new Color(0.5f, 0.5f, 1.0f, 1.0f); component.SetSymbolVisiblity("gun_target", is_visible: false); bool symbolVisible; Vector4 column = component.GetSymbolTransform(new HashedString("gun_target"), out symbolVisible).GetColumn(3); Vector3 position = column; position.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm); this.arm_go.transform.SetPosition(position); this.arm_go.SetActive(value: true); this.link = new KAnimLink(component, this.arm_anim_ctrl); this.SetupBeam(); this.RotateArm(this.rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -this.arm_rot) * Vector3.up), warp: true, 0f); this.energyConsumer.UpdatePoweredStatus(); this.operational.SetActive(true); this.selectable.AddStatusItem(charge_status, this); this.selectable.AddStatusItem(kills_status, this); }
public void HideSymbols() { if (!((Object)EntityPrefabs.Instance == (Object)null) && !isForeground) { KAnimFile[] animFiles = controller.AnimFiles; bool flag = IsAnimLayered(animFiles); if (flag && (Object)foregroundController == (Object)null && layer != Grid.SceneLayer.NoLayer) { GameObject gameObject = Util.KInstantiate(EntityPrefabs.Instance.ForegroundLayer, controller.gameObject, null); gameObject.name = controller.name + "_fg"; foregroundController = gameObject.GetComponent <KAnimControllerBase>(); foregroundController.AnimFiles = animFiles; foregroundController.GetLayering().SetIsForeground(true); foregroundController.initialAnim = controller.initialAnim; link = new KAnimLink(controller, foregroundController); Dirty(); KAnimSynchronizer synchronizer = controller.GetSynchronizer(); synchronizer.Add(foregroundController); synchronizer.Sync(foregroundController); float layerZ = Grid.GetLayerZ(layer); Vector3 position = controller.gameObject.transform.GetPosition(); Vector3 position2 = new Vector3(0f, 0f, layerZ - position.z - 0.1f); gameObject.transform.SetLocalPosition(position2); gameObject.SetActive(true); } else if (!flag && (Object)foregroundController != (Object)null) { controller.GetSynchronizer().Remove(foregroundController); foregroundController.gameObject.DeleteObject(); link = null; } if ((Object)foregroundController != (Object)null) { HideSymbolsInternal(); foregroundController.GetLayering()?.HideSymbolsInternal(); } } }
protected override void OnSpawn() { base.OnSpawn(); hitEffectPrefab = Assets.GetPrefab("fx_dig_splash"); KBatchedAnimController component = GetComponent <KBatchedAnimController>(); string name = component.name + ".gun"; arm_go = new GameObject(name); arm_go.SetActive(false); arm_go.transform.parent = component.transform; looping_sounds = arm_go.AddComponent <LoopingSounds>(); rotateSound = GlobalAssets.GetSound(rotateSound, false); KPrefabID kPrefabID = arm_go.AddComponent <KPrefabID>(); kPrefabID.PrefabTag = new Tag(name); arm_anim_ctrl = arm_go.AddComponent <KBatchedAnimController>(); arm_anim_ctrl.AnimFiles = new KAnimFile[1] { component.AnimFiles[0] }; arm_anim_ctrl.initialAnim = "gun"; arm_anim_ctrl.isMovable = true; arm_anim_ctrl.sceneLayer = Grid.SceneLayer.TransferArm; component.SetSymbolVisiblity("gun_target", false); bool symbolVisible; Vector4 column = component.GetSymbolTransform(new HashedString("gun_target"), out symbolVisible).GetColumn(3); Vector3 position = column; position.z = Grid.GetLayerZ(Grid.SceneLayer.TransferArm); arm_go.transform.SetPosition(position); arm_go.SetActive(true); link = new KAnimLink(component, arm_anim_ctrl); Subscribe(-592767678, OnOperationalChangedDelegate); RotateArm(rotatable.GetRotatedOffset(Quaternion.Euler(0f, 0f, -45f) * Vector3.up), true, 0f); StopDig(); base.smi.StartSM(); }
private void Initialize(KAnimControllerBase building_controller, string meter_target, string meter_animation, Meter.Offset front_back, Grid.SceneLayer user_specified_render_layer, Vector3 tracker_offset, params string[] symbols_to_hide) { string name = building_controller.name + "." + meter_animation; GameObject gameObject = UnityEngine.Object.Instantiate(Assets.GetPrefab(MeterConfig.ID)); gameObject.name = name; gameObject.SetActive(false); gameObject.transform.parent = building_controller.transform; this.gameObject = gameObject; KPrefabID component = gameObject.GetComponent <KPrefabID>(); component.PrefabTag = new Tag(name); Vector3 position = building_controller.transform.GetPosition(); switch (front_back) { case Meter.Offset.Behind: { Vector3 position3 = building_controller.transform.GetPosition(); position.z = position3.z + 0.1f; break; } case Meter.Offset.Infront: { Vector3 position2 = building_controller.transform.GetPosition(); position.z = position2.z - 0.1f; break; } case Meter.Offset.UserSpecified: position.z = Grid.GetLayerZ(user_specified_render_layer); break; } gameObject.transform.SetPosition(position); KBatchedAnimController component2 = gameObject.GetComponent <KBatchedAnimController>(); component2.AnimFiles = new KAnimFile[1] { building_controller.AnimFiles[0] }; component2.initialAnim = meter_animation; component2.fgLayer = Grid.SceneLayer.NoLayer; component2.initialMode = KAnim.PlayMode.Paused; component2.isMovable = true; component2.FlipX = building_controller.FlipX; component2.FlipY = building_controller.FlipY; if (front_back == Meter.Offset.UserSpecified) { component2.sceneLayer = user_specified_render_layer; } meterController = component2; KBatchedAnimTracker component3 = gameObject.GetComponent <KBatchedAnimTracker>(); component3.offset = tracker_offset; component3.symbol = new HashedString(meter_target); gameObject.SetActive(true); building_controller.SetSymbolVisiblity(meter_target, false); if (symbols_to_hide != null) { for (int i = 0; i < symbols_to_hide.Length; i++) { building_controller.SetSymbolVisiblity(symbols_to_hide[i], false); } } link = new KAnimLink(building_controller, component2); }