public override void InitializeStates(out BaseState default_state) { default_state = closed; base.serializable = true; closed.PlayAnim("on").Enter(delegate(StatesInstance smi) { if (smi.master.machineSound != null) { LoopingSounds component2 = smi.master.GetComponent <LoopingSounds>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { component2.StartSound(GlobalAssets.GetSound(smi.master.machineSound, false)); } } }); open.PlayAnim("working").OnAnimQueueComplete(off).Exit(delegate(StatesInstance smi) { smi.master.DropContents(); }); off.PlayAnim("off").Enter(delegate(StatesInstance smi) { if (smi.master.machineSound != null) { LoopingSounds component = smi.master.GetComponent <LoopingSounds>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.StopSound(GlobalAssets.GetSound(smi.master.machineSound, false)); } } }); }
protected override void OnPrefabInit() { base.OnPrefabInit(); remainingTileDamage = totalTileDamage; loopingSounds = base.gameObject.GetComponent <LoopingSounds>(); flyingSound = GlobalAssets.GetSound("Meteor_LP", false); }
public GameObject CreatePrefab() { string text = STRINGS.CREATURES.SPECIES.GLOM.NAME; string id = "Glom"; string name = text; string desc = STRINGS.CREATURES.SPECIES.GLOM.DESC; float mass = 25f; KAnimFile anim = Assets.GetAnim("glom_kanim"); string initialAnim = "idle_loop"; EffectorValues tIER = DECOR.BONUS.TIER0; GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, anim, initialAnim, Grid.SceneLayer.Creatures, 1, 1, tIER, default(EffectorValues), SimHashes.Creature, null, 293f); Trait trait = Db.Get().CreateTrait("GlomBaseTrait", text, text, null, false, null, true, true); trait.Add(new AttributeModifier(Db.Get().Amounts.HitPoints.maxAttribute.Id, 25f, text, false, false, true)); KPrefabID component = gameObject.GetComponent <KPrefabID>(); component.AddTag(GameTags.Creatures.Walker, false); component.prefabInitFn += delegate(GameObject inst) { inst.GetAttributes().Add(Db.Get().Attributes.MaxUnderwaterTravelCost); }; EntityTemplates.ExtendEntityToBasicCreature(gameObject, FactionManager.FactionID.Pest, "GlomBaseTrait", "WalkerNavGrid1x1", NavType.Floor, 32, 2f, string.Empty, 0, true, true, 293.15f, 393.15f, 273.15f, 423.15f); gameObject.AddWeapon(1f, 1f, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f); gameObject.AddOrGet <Trappable>(); gameObject.AddOrGetDef <ThreatMonitor.Def>(); gameObject.AddOrGetDef <CreatureFallMonitor.Def>(); ElementDropperMonitor.Def def = gameObject.AddOrGetDef <ElementDropperMonitor.Def>(); def.dirtyEmitElement = SimHashes.ContaminatedOxygen; def.dirtyProbabilityPercent = 25f; def.dirtyCellToTargetMass = 1f; def.dirtyMassPerDirty = 0.2f; def.dirtyMassReleaseOnDeath = 3f; def.emitDiseaseIdx = Db.Get().Diseases.GetIndex("SlimeLung"); def.emitDiseasePerKg = 1000f; OvercrowdingMonitor.Def def2 = gameObject.AddOrGetDef <OvercrowdingMonitor.Def>(); def2.spaceRequiredPerCreature = 0; gameObject.AddOrGet <LoopingSounds>(); LoopingSounds component2 = gameObject.GetComponent <LoopingSounds>(); component2.updatePosition = true; DiseaseSourceVisualizer diseaseSourceVisualizer = gameObject.AddOrGet <DiseaseSourceVisualizer>(); diseaseSourceVisualizer.alwaysShowDisease = "SlimeLung"; SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_movement_short", NOISE_POLLUTION.CREATURES.TIER2); SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_jump", NOISE_POLLUTION.CREATURES.TIER3); SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_land", NOISE_POLLUTION.CREATURES.TIER3); SoundEventVolumeCache.instance.AddVolume("glom_kanim", "Morb_expel", NOISE_POLLUTION.CREATURES.TIER4); EntityTemplates.CreateAndRegisterBaggedCreature(gameObject, true, false, false); ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new TrappedStates.Def(), true).Add(new BaggedStates.Def(), true) .Add(new FallStates.Def(), true) .Add(new StunnedStates.Def(), true) .Add(new DrowningStates.Def(), true) .Add(new DebugGoToStates.Def(), true) .Add(new FleeStates.Def(), true) .Add(new DropElementStates.Def(), true) .Add(new IdleStates.Def(), true); EntityTemplates.AddCreatureBrain(gameObject, chore_table, GameTags.Creatures.Species.GlomSpecies, null); return(gameObject); }
public void StopInhaleSound() { LoopingSounds component = GetComponent <LoopingSounds>(); if ((Object)component != (Object)null) { component.StopSound(base.smi.inhaleSound); } }
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(); }
private void UpdateSound() { bool flag = isMoving && GetComponent <Navigator>().CurrentNavType != NavType.Swim; if (flag != isPlayingSound) { LoopingSounds component = GetComponent <LoopingSounds>(); if (flag) { component.StartSound(sound); } else { component.StopSound(sound); } isPlayingSound = flag; } }
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); }
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(); }
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 SetupLoopingSounds(GameObject inst) { LoopingSounds component = inst.GetComponent <LoopingSounds>(); component.StartSound(GlobalAssets.GetSound("ShineBug_wings_LP", false)); }
public GameObject CreatePrefab() { string name = DUPLICANTS.MODIFIERS.BASEDUPLICANT.NAME; GameObject gameObject = EntityTemplates.CreateEntity(ID, name, true); gameObject.AddOrGet <StateMachineController>(); MinionModifiers modifiers = gameObject.AddOrGet <MinionModifiers>(); AddMinionAmounts(modifiers); AddMinionTraits(name, modifiers); gameObject.AddOrGet <MinionBrain>(); gameObject.AddOrGet <KPrefabID>().AddTag(GameTags.DupeBrain, false); gameObject.AddOrGet <Worker>(); gameObject.AddOrGet <ChoreConsumer>(); Storage storage = gameObject.AddOrGet <Storage>(); storage.fxPrefix = Storage.FXPrefix.PickedUp; storage.dropOnLoad = true; storage.SetDefaultStoredItemModifiers(new List <Storage.StoredItemModifier> { Storage.StoredItemModifier.Preserve, Storage.StoredItemModifier.Seal }); gameObject.AddOrGet <Health>(); OxygenBreather oxygenBreather = gameObject.AddOrGet <OxygenBreather>(); oxygenBreather.O2toCO2conversion = 0.02f; oxygenBreather.lowOxygenThreshold = 0.52f; oxygenBreather.noOxygenThreshold = 0.05f; oxygenBreather.mouthOffset = new Vector2f(0.25f, 0.7f); oxygenBreather.minCO2ToEmit = 0.02f; oxygenBreather.breathableCells = new CellOffset[6] { new CellOffset(0, 0), new CellOffset(0, 1), new CellOffset(1, 1), new CellOffset(-1, 1), new CellOffset(1, 0), new CellOffset(-1, 0) }; gameObject.AddOrGet <WarmBlooded>(); gameObject.AddOrGet <MinionIdentity>(); GridVisibility gridVisibility = gameObject.AddOrGet <GridVisibility>(); gridVisibility.radius = 30f; gridVisibility.innerRadius = 20f; gameObject.AddOrGet <MiningSounds>(); gameObject.AddOrGet <SaveLoadRoot>(); gameObject.AddOrGet <AntiCluster>(); Navigator navigator = gameObject.AddOrGet <Navigator>(); navigator.NavGridName = "MinionNavGrid"; navigator.CurrentNavType = NavType.Floor; KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.isMovable = true; kBatchedAnimController.sceneLayer = Grid.SceneLayer.Move; kBatchedAnimController.AnimFiles = new KAnimFile[8] { Assets.GetAnim("body_comp_default_kanim"), Assets.GetAnim("anim_construction_default_kanim"), Assets.GetAnim("anim_idles_default_kanim"), Assets.GetAnim("anim_loco_firepole_kanim"), Assets.GetAnim("anim_loco_new_kanim"), Assets.GetAnim("anim_loco_tube_kanim"), Assets.GetAnim("anim_construction_firepole_kanim"), Assets.GetAnim("anim_construction_jetsuit_kanim") }; KBoxCollider2D kBoxCollider2D = gameObject.AddOrGet <KBoxCollider2D>(); kBoxCollider2D.offset = new Vector2(0f, 0.8f); kBoxCollider2D.size = new Vector2(1f, 1.5f); SnapOn snapOn = gameObject.AddOrGet <SnapOn>(); snapOn.snapPoints = new List <SnapOn.SnapPoint>(new SnapOn.SnapPoint[17] { new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"dig", buildFile = Assets.GetAnim("excavator_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"build", buildFile = Assets.GetAnim("constructor_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"fetchliquid", buildFile = Assets.GetAnim("water_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"paint", buildFile = Assets.GetAnim("painting_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"harvest", buildFile = Assets.GetAnim("plant_harvester_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"capture", buildFile = Assets.GetAnim("net_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"attack", buildFile = Assets.GetAnim("attack_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"pickup", buildFile = Assets.GetAnim("pickupdrop_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"store", buildFile = Assets.GetAnim("pickupdrop_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"disinfect", buildFile = Assets.GetAnim("plant_spray_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"tend", buildFile = Assets.GetAnim("plant_harvester_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "carry", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_chest" }, new SnapOn.SnapPoint { pointName = "build", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "remote", automatic = false, context = (HashedString)string.Empty, buildFile = null, overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "snapTo_neck", automatic = false, context = (HashedString)string.Empty, buildFile = Assets.GetAnim("helm_oxygen_kanim"), overrideSymbol = (HashedString)"snapTo_neck" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"powertinker", buildFile = Assets.GetAnim("electrician_gun_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" }, new SnapOn.SnapPoint { pointName = "dig", automatic = false, context = (HashedString)"specialistdig", buildFile = Assets.GetAnim("excavator_kanim"), overrideSymbol = (HashedString)"snapTo_rgtHand" } }); gameObject.AddOrGet <Effects>(); gameObject.AddOrGet <Traits>(); gameObject.AddOrGet <AttributeLevels>(); gameObject.AddOrGet <AttributeConverters>(); PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>(); primaryElement.InternalTemperature = 310.15f; primaryElement.MassPerUnit = 30f; primaryElement.ElementID = SimHashes.Creature; gameObject.AddOrGet <ChoreProvider>(); gameObject.AddOrGetDef <DebugGoToMonitor.Def>(); gameObject.AddOrGetDef <SpeechMonitor.Def>(); gameObject.AddOrGetDef <BlinkMonitor.Def>(); gameObject.AddOrGetDef <ConversationMonitor.Def>(); gameObject.AddOrGet <Sensors>(); gameObject.AddOrGet <Chattable>(); gameObject.AddOrGet <FaceGraph>(); gameObject.AddOrGet <Accessorizer>(); gameObject.AddOrGet <Schedulable>(); LoopingSounds loopingSounds = gameObject.AddOrGet <LoopingSounds>(); loopingSounds.updatePosition = true; gameObject.AddOrGet <AnimEventHandler>(); FactionAlignment factionAlignment = gameObject.AddOrGet <FactionAlignment>(); factionAlignment.Alignment = FactionManager.FactionID.Duplicant; gameObject.AddOrGet <Weapon>(); gameObject.AddOrGet <RangedAttackable>(); gameObject.AddOrGet <CharacterOverlay>(); OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>(); occupyArea.objectLayers = new ObjectLayer[1]; occupyArea.ApplyToCells = false; occupyArea.OccupiedCellsOffsets = new CellOffset[2] { new CellOffset(0, 0), new CellOffset(0, 1) }; gameObject.AddOrGet <Pickupable>(); CreatureSimTemperatureTransfer creatureSimTemperatureTransfer = gameObject.AddOrGet <CreatureSimTemperatureTransfer>(); creatureSimTemperatureTransfer.SurfaceArea = 10f; creatureSimTemperatureTransfer.Thickness = 0.01f; gameObject.AddOrGet <SicknessTrigger>(); gameObject.AddOrGet <ClothingWearer>(); gameObject.AddOrGet <SuitEquipper>(); DecorProvider decorProvider = gameObject.AddOrGet <DecorProvider>(); decorProvider.baseRadius = 3f; decorProvider.isMovable = true; gameObject.AddOrGet <ConsumableConsumer>(); gameObject.AddOrGet <NoiseListener>(); gameObject.AddOrGet <MinionResume>(); DuplicantNoiseLevels.SetupNoiseLevels(); SetupLaserEffects(gameObject); SymbolOverrideController symbolOverrideController = SymbolOverrideControllerUtil.AddToPrefab(gameObject); symbolOverrideController.applySymbolOverridesEveryFrame = true; ConfigureSymbols(gameObject); return(gameObject); }