public static float MaximumAttribute(string attributeName) { float max = 0; foreach (MinionIdentity identity in Components.MinionIdentities) { MinionModifiers modifiers = identity.GetComponent <MinionModifiers>(); if (modifiers == null) { continue; } Klei.AI.AttributeInstance attributeInstance = modifiers.attributes.AttributeTable.Where(p => p.Name == attributeName).FirstOrDefault(); if (attributeInstance == null) { continue; } float value = attributeInstance.GetTotalValue(); if (value > max) { max = value; } } return(max); }
private void TriggerRoomEffects(object data) { if (!RoomTypes_AllModded.IsInTheRoom(this, RoomTypeMuseumData.RoomId)) { return; } if (!Settings.Instance.Museum.Bonus.HasValue) { return; } GameObject gameObject = (GameObject)data; MinionModifiers modifiers = gameObject.GetComponent <MinionModifiers>(); if (modifiers == null) { return; } AttributeInstance attributeInstance = modifiers.attributes.AttributeTable.Where(p => p.Name == "Creativity").FirstOrDefault(); if (attributeInstance == null) { return; } float creativity = attributeInstance.GetTotalValue(); int moraleBonus = (int)Math.Ceiling(creativity * Settings.Instance.Museum.Bonus.Value); if (moraleBonus < 1) { moraleBonus = 1; } if (moraleBonus > 10) { moraleBonus = 10; } Effect effect = new Effect(RoomTypeMuseumData.EffectId, STRINGS.ROOMS.EFFECTS.MUSEUM.NAME, STRINGS.ROOMS.EFFECTS.MUSEUM.DESCRIPTION, 240, false, true, false); effect.SelfModifiers = new System.Collections.Generic.List <AttributeModifier>(); effect.SelfModifiers.Add(new AttributeModifier("QualityOfLife", moraleBonus, description: STRINGS.ROOMS.EFFECTS.MUSEUM.NAME)); Effects effects = gameObject.GetComponent <Effects>(); if (effects != null && !effects.HasEffect(RoomTypeMuseumData.EffectId)) { effects.Add(effect, true); } }
public GameObject CreatePrefab() { GameObject gameObject = EntityTemplates.CreateEntity(ID, ID, true); RectTransform rectTransform = gameObject.AddOrGet <RectTransform>(); rectTransform.anchorMin = new Vector2(0f, 0f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 0f); rectTransform.sizeDelta = new Vector2(0f, 0f); LayoutElement layoutElement = gameObject.AddOrGet <LayoutElement>(); layoutElement.preferredHeight = 100f; layoutElement.preferredWidth = 100f; gameObject.AddOrGet <Effects>(); gameObject.AddOrGet <Traits>(); MinionModifiers minionModifiers = gameObject.AddOrGet <MinionModifiers>(); minionModifiers.initialTraits = new string[1] { MinionConfig.MINION_BASE_TRAIT_ID }; MinionConfig.AddMinionAmounts(minionModifiers); gameObject.AddOrGet <AttributeLevels>(); gameObject.AddOrGet <AttributeConverters>(); MinionIdentity minionIdentity = gameObject.AddOrGet <MinionIdentity>(); minionIdentity.addToIdentityList = false; BoxCollider2D boxCollider2D = gameObject.AddOrGet <BoxCollider2D>(); boxCollider2D.size = new Vector2(1f, 1f); gameObject.AddOrGet <FaceGraph>(); gameObject.AddOrGet <Accessorizer>(); KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.materialType = KAnimBatchGroup.MaterialType.UI; kBatchedAnimController.animScale = 0.5f; kBatchedAnimController.setScaleFromAnim = false; kBatchedAnimController.animOverrideSize = new Vector2(100f, 120f); kBatchedAnimController.AnimFiles = new KAnimFile[4] { Assets.GetAnim("body_comp_default_kanim"), Assets.GetAnim("anim_construction_default_kanim"), Assets.GetAnim("anim_idles_default_kanim"), Assets.GetAnim("anim_cheer_kanim") }; SymbolOverrideControllerUtil.AddToPrefab(gameObject); MinionConfig.ConfigureSymbols(gameObject); return(gameObject); }
public static void OnDeathPost(MinionModifiers __instance) { int[] pos = getDropSpawnLocation(__instance.gameObject); foreach (int p in pos) { GameObject gameObject = Scenario.SpawnPrefab(p, 0, 0, "Meat", Grid.SceneLayer.Ore); gameObject.SetActive(true); Edible component2 = gameObject.GetComponent <Edible>(); if (component2 != null) { ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, component2.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.BUTCHERED, "{0}", gameObject.GetProperName()), UI.ENDOFDAYREPORT.NOTES.BUTCHERED_CONTEXT); } } }
private static void StoreModifiers(MinionIdentity src_id, StoredMinionIdentity dest_id) { MinionModifiers component = src_id.GetComponent <MinionModifiers>(); foreach (AttributeInstance attribute in component.attributes) { if (dest_id.minionModifiers.attributes.Get(attribute.Attribute.Id) == null) { dest_id.minionModifiers.attributes.Add(attribute.Attribute); } for (int i = 0; i < attribute.Modifiers.Count; i++) { dest_id.minionModifiers.attributes.Get(attribute.Id).Add(attribute.Modifiers[i]); } } }
public static int SickDuplicants(string diseaseId) { int count = 0; foreach (MinionIdentity identity in Components.MinionIdentities) { MinionModifiers modifiers = identity.GetComponent <MinionModifiers>(); if (modifiers == null) { continue; } foreach (Klei.AI.SicknessInstance sickness in modifiers.sicknesses.ModifierList) { if (sickness.Sickness.Id == diseaseId) { count++; } } } return(count); }
private bool CanAutoAssignTo(MinionAssignablesProxy worker) { bool flag = false; MinionIdentity minionIdentity = worker.target as MinionIdentity; if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null) { if (IsValidEffect(healthEffect)) { Health component = minionIdentity.GetComponent <Health>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.hitPoints < component.maxHitPoints) { flag = true; } } if (!flag && IsValidEffect(diseaseEffect)) { MinionModifiers component2 = minionIdentity.GetComponent <MinionModifiers>(); Sicknesses sicknesses = component2.sicknesses; flag = (sicknesses.Count > 0); } } return(flag); }
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); }