private void OnResetSettingsClicked() { if (Game.Instance.advancedPersonalPriorities) { if ((UnityEngine.Object)Immigration.Instance != (UnityEngine.Object)null) { Immigration.Instance.ResetPersonalPriorities(); } foreach (MinionIdentity item in Components.LiveMinionIdentities.Items) { if (!((UnityEngine.Object)item == (UnityEngine.Object)null)) { Immigration.Instance.ApplyDefaultPersonalPriorities(item.gameObject); } } } else { foreach (MinionIdentity item2 in Components.LiveMinionIdentities.Items) { if (!((UnityEngine.Object)item2 == (UnityEngine.Object)null)) { ChoreConsumer component = item2.GetComponent <ChoreConsumer>(); foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources) { component.SetPersonalPriority(resource, 3); } } } } MarkRowsDirty(); }
public StatesInstance(ChoreDriver master) : base(master) { ChoreConsumer component = GetComponent <ChoreConsumer>(); component.choreRulesChanged = (System.Action)Delegate.Combine(component.choreRulesChanged, new System.Action(OnChoreRulesChanged)); }
public bool CanBegin(GameObject reactor, Navigator.ActiveTransition transition) { if (GameClock.Instance.GetTime() - lastTriggerTime < minReactableTime) { return(false); } ChoreConsumer component = reactor.GetComponent <ChoreConsumer>(); if ((Object)component == (Object)null) { return(false); } Chore currentChore = component.choreDriver.GetCurrentChore(); if (currentChore == null) { return(false); } if (choreType.priority <= currentChore.choreType.priority) { return(false); } if (additionalPreconditions != null) { foreach (ReactablePrecondition additionalPrecondition in additionalPreconditions) { if (!additionalPrecondition(reactor, transition)) { return(false); } } } return(InternalCanBegin(reactor, transition)); }
private static string TooltipForChore(Chore.Precondition.Context context, ChoreConsumer choreConsumer) { bool flag = context.chore.masterPriority.priority_class == PriorityScreen.PriorityClass.basic || context.chore.masterPriority.priority_class == PriorityScreen.PriorityClass.high; string text; switch (context.chore.masterPriority.priority_class) { case PriorityScreen.PriorityClass.idle: text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLE; break; case PriorityScreen.PriorityClass.personalNeeds: text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_PERSONAL; break; case PriorityScreen.PriorityClass.topPriority: text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_EMERGENCY; break; case PriorityScreen.PriorityClass.compulsory: text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_COMPULSORY; break; default: text = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_NORMAL; break; } float num = 0f; int num2 = (int)context.chore.masterPriority.priority_class * 100; num += (float)num2; int num3 = flag ? choreConsumer.GetPersonalPriority(context.chore.choreType) : 0; num += (float)(num3 * 10); int num4 = flag ? context.chore.masterPriority.priority_value : 0; num += (float)num4; float num5 = (float)context.priority / 10000f; num += num5; text = text.Replace("{Description}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_DESC_INACTIVE : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_DESC_ACTIVE); text = text.Replace("{IdleDescription}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLEDESC_INACTIVE : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_IDLEDESC_ACTIVE); string newValue = GameUtil.ChoreGroupsForChoreType(context.chore.choreType); ChoreGroup choreGroup = BestPriorityGroup(context, choreConsumer); text = text.Replace("{Name}", choreConsumer.name); text = text.Replace("{Errand}", GameUtil.GetChoreName(context.chore, context.data)); text = text.Replace("{Groups}", newValue); text = text.Replace("{BestGroup}", (choreGroup == null) ? context.chore.choreType.Name : choreGroup.Name); text = text.Replace("{ClassPriority}", num2.ToString()); string text2 = text; JobsTableScreen.PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[num3]; text = text2.Replace("{PersonalPriority}", priorityInfo.name.text); text = text.Replace("{PersonalPriorityValue}", (num3 * 10).ToString()); text = text.Replace("{Building}", context.chore.gameObject.GetProperName()); text = text.Replace("{BuildingPriority}", num4.ToString()); text = text.Replace("{TypePriority}", num5.ToString()); return(text.Replace("{TotalPriority}", num.ToString())); }
public void Init(BuildingChoresPanel.DupeEntryData data) { choreConsumer = data.consumer; if (data.context.IsPotentialSuccess()) { string newValue = (!((Object)data.context.chore.driver == (Object)data.consumer.choreDriver)) ? string.Format(DUPLICANTS.CHORES.PRECONDITIONS.RANK_FORMAT.text, data.rank) : DUPLICANTS.CHORES.PRECONDITIONS.CURRENT_ERRAND.text; label.text = DUPLICANTS.CHORES.PRECONDITIONS.SUCCESS_ROW.Replace("{Duplicant}", data.consumer.name).Replace("{Rank}", newValue); } else { Chore.PreconditionInstance preconditionInstance = data.context.chore.GetPreconditions()[data.context.failedPreconditionId]; string text = preconditionInstance.description; bool test = text != null; Chore.PreconditionInstance preconditionInstance2 = data.context.chore.GetPreconditions()[data.context.failedPreconditionId]; DebugUtil.Assert(test, "Chore requires description!", preconditionInstance2.id); if ((Object)data.context.chore.driver != (Object)null) { text = text.Replace("{Assignee}", data.context.chore.driver.GetProperName()); } text = text.Replace("{Selected}", data.context.chore.gameObject.GetProperName()); label.text = DUPLICANTS.CHORES.PRECONDITIONS.FAILURE_ROW.Replace("{Duplicant}", data.consumer.name).Replace("{Reason}", text); } Image image = icon; JobsTableScreen.PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[data.personalPriority]; image.sprite = priorityInfo.sprite; toolTip.toolTip = TooltipForDupe(data.context, data.consumer, data.rank); }
protected override void OnPrefabInit() { base.OnPrefabInit(); if (addBaseTraits) { foreach (Klei.AI.Attribute resource in Db.Get().Attributes.resources) { if (attributes.Get(resource) == null) { attributes.Add(resource); } } Traits component = GetComponent <Traits>(); Trait trait = Db.Get().traits.Get(MinionConfig.MINION_BASE_TRAIT_ID); component.Add(trait); foreach (Disease resource2 in Db.Get().Diseases.resources) { AmountInstance amountInstance = AddAmount(resource2.amount); attributes.Add(resource2.cureSpeedBase); amountInstance.SetValue(0f); } ChoreConsumer component2 = GetComponent <ChoreConsumer>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { component2.AddProvider(GlobalChoreProvider.Instance); base.gameObject.AddComponent <QualityOfLifeNeed>(); } } }
public Instance(IStateMachineTarget master) : base(master) { ChoreConsumer component = GetComponent <ChoreConsumer>(); component.AddUrge(Db.Get().Urges.EmoteHighPriority); component.AddUrge(Db.Get().Urges.EmoteIdle); }
protected override void OnCleanUp() { base.OnCleanUp(); if ((UnityEngine.Object) this.consumer != (UnityEngine.Object)null) { ChoreConsumer consumer = this.consumer; consumer.choreRulesChanged = (System.Action)Delegate.Remove(consumer.choreRulesChanged, new System.Action(Dirty)); } }
protected override void OnSpawn() { base.OnSpawn(); consumer = gameObject.GetComponent <ChoreConsumer>(); driver = gameObject.GetComponent <ChoreDriver>(); Subscribe((int)GameHashes.ScheduleBlocksChanged, OnScheduleChanged); lastGroupID = CurrentScheduleBlock; acquireChore = lastGroupID == FinishTasksPatches.FinishTask.Id; allowedChore = null; }
public void SetOverrideTarget(ChoreConsumer chore_consumer) { string text = "null"; if ((UnityEngine.Object)chore_consumer != (UnityEngine.Object)null) { text = chore_consumer.name; } overrideTarget = chore_consumer; Fail("New override target"); }
public Reservation(ChoreConsumer consumer, Pickupable pickupable, float reservation_amount) { this = default(Reservation); if (reservation_amount <= 0f) { Debug.LogError("Invalid amount: " + reservation_amount); } amount = reservation_amount; this.pickupable = pickupable; handle = pickupable.Reserve("FetchAreaChore", consumer.gameObject, reservation_amount); }
private void OnChoreRulesChanged() { Chore currentChore = GetCurrentChore(); if (currentChore != null) { ChoreConsumer component = GetComponent <ChoreConsumer>(); if (!component.IsPermittedOrEnabled(currentChore.choreType, currentChore)) { EndChore("Permissions changed"); } } }
private static string TooltipForDupe(Chore.Precondition.Context context, ChoreConsumer choreConsumer, int rank) { bool flag = context.IsPotentialSuccess(); string text = (!flag) ? UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_FAILED : UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_SUCCEEDED; float num = 0f; int personalPriority = choreConsumer.GetPersonalPriority(context.chore.choreType); num += (float)(personalPriority * 10); int priority_value = context.chore.masterPriority.priority_value; num += (float)priority_value; float num2 = (float)context.priority / 10000f; num += num2; text = text.Replace("{Description}", (!((Object)context.chore.driver == (Object)choreConsumer.choreDriver)) ? UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_DESC_INACTIVE : UI.DETAILTABS.BUILDING_CHORES.DUPE_TOOLTIP_DESC_ACTIVE); string newValue = GameUtil.ChoreGroupsForChoreType(context.chore.choreType); string newValue2 = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.TOOLTIP_NA.text; if (flag && context.chore.choreType.groups.Length > 0) { ChoreGroup choreGroup = context.chore.choreType.groups[0]; for (int i = 1; i < context.chore.choreType.groups.Length; i++) { if (choreConsumer.GetPersonalPriority(choreGroup) < choreConsumer.GetPersonalPriority(context.chore.choreType.groups[i])) { choreGroup = context.chore.choreType.groups[i]; } } newValue2 = choreGroup.Name; } text = text.Replace("{Name}", choreConsumer.name); text = text.Replace("{Errand}", GameUtil.GetChoreName(context.chore, context.data)); if (flag) { text = text.Replace("{Rank}", rank.ToString()); text = text.Replace("{Groups}", newValue); text = text.Replace("{BestGroup}", newValue2); string text2 = text; JobsTableScreen.PriorityInfo priorityInfo = JobsTableScreen.priorityInfo[personalPriority]; text = text2.Replace("{PersonalPriority}", priorityInfo.name.text); text = text.Replace("{PersonalPriorityValue}", (personalPriority * 10).ToString()); text = text.Replace("{Building}", context.chore.gameObject.GetProperName()); text = text.Replace("{BuildingPriority}", priority_value.ToString()); text = text.Replace("{TypePriority}", num2.ToString()); return(text.Replace("{TotalPriority}", num.ToString())); } string text3 = text; Chore.PreconditionInstance preconditionInstance = context.chore.GetPreconditions()[context.failedPreconditionId]; return(text3.Replace("{FailedPrecondition}", preconditionInstance.description)); }
public void Apply(Chore.Precondition.Context context) { ChoreConsumer consumer = context.consumerState.consumer; if (targetChore != context.chore || !object.ReferenceEquals(context.chore.target, lastChoreTarget) || !(context.chore.masterPriority == lastPrioritySetting)) { targetChore = context.chore; lastChoreTarget = context.chore.target; lastPrioritySetting = context.chore.masterPriority; string choreName = GameUtil.GetChoreName(context.chore, context.data); string text = GameUtil.ChoreGroupsForChoreType(context.chore.choreType); string text2 = UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CHORE_TARGET; text2 = text2.Replace("{Target}", (!((Object)context.chore.target.gameObject == (Object)consumer.gameObject)) ? context.chore.target.gameObject.GetProperName() : UI.UISIDESCREENS.MINIONTODOSIDESCREEN.SELF_LABEL.text); if (text != null) { text2 = text2.Replace("{Groups}", text); } string text3 = (context.chore.masterPriority.priority_class != 0) ? string.Empty : context.chore.masterPriority.priority_value.ToString(); Sprite sprite = (context.chore.masterPriority.priority_class != 0) ? null : prioritySprites[context.chore.masterPriority.priority_value - 1]; ChoreGroup choreGroup = BestPriorityGroup(context, consumer); icon.sprite = ((choreGroup == null) ? null : Assets.GetSprite(choreGroup.sprite)); label.SetText(choreName); subLabel.SetText(text2); priorityLabel.SetText(text3); priorityIcon.sprite = sprite; moreLabel.text = string.Empty; GetComponent <ToolTip>().SetSimpleTooltip(TooltipForChore(context, consumer)); KButton componentInChildren = GetComponentInChildren <KButton>(); componentInChildren.ClearOnClick(); if ((Object)componentInChildren.bgImage != (Object)null) { componentInChildren.bgImage.colorStyleSetting = ((!((Object)context.chore.driver == (Object)consumer.choreDriver)) ? buttonColorSettingStandard : buttonColorSettingCurrent); componentInChildren.bgImage.ApplyColorStyleSetting(); } GameObject gameObject = context.chore.target.gameObject; componentInChildren.ClearOnPointerEvents(); componentInChildren.GetComponentInChildren <KButton>().onClick += delegate { if (context.chore != null && !context.chore.target.isNull) { Vector3 position = context.chore.target.gameObject.transform.position; float x = position.x; Vector3 position2 = context.chore.target.gameObject.transform.position; float y = position2.y + 1f; Vector3 position3 = CameraController.Instance.transform.position; Vector3 pos = new Vector3(x, y, position3.z); CameraController.Instance.SetTargetPos(pos, 10f, true); } }; } }
public override void RemoveFrom(Attributes attributes) { base.RemoveFrom(attributes); ChoreConsumer component = attributes.gameObject.GetComponent <ChoreConsumer>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null && disabledChoreGroups != null) { ChoreGroup[] array = disabledChoreGroups; foreach (ChoreGroup chore_group in array) { component.SetPermittedByTraits(chore_group, true); } } }
public override void Populate(MinionIdentity _identity) { base.Populate(_identity); this.consumer = _identity.GetComponent <ChoreConsumer>(); ChoreConsumer consumer = this.consumer; consumer.choreRulesChanged = (System.Action)Delegate.Combine(consumer.choreRulesChanged, new System.Action(Dirty)); foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources) { CreateChoreButton(resource); } CreateAllTaskButton(); dirty = true; }
private void CopyMinion(MinionIdentity src_id, StoredMinionIdentity dest_id) { dest_id.storedName = src_id.name; dest_id.nameStringKey = src_id.nameStringKey; dest_id.gender = src_id.gender; dest_id.genderStringKey = src_id.genderStringKey; dest_id.arrivalTime = src_id.arrivalTime; dest_id.voiceIdx = src_id.voiceIdx; dest_id.bodyData = src_id.bodyData; Traits component = src_id.GetComponent <Traits>(); dest_id.traitIDs = new List <string>(component.GetTraitIds()); dest_id.assignableProxy.Set(src_id.assignableProxy.Get()); dest_id.assignableProxy.Get().SetTarget(dest_id, dest_id.gameObject); Accessorizer component2 = src_id.GetComponent <Accessorizer>(); dest_id.accessories = component2.GetAccessories(); ConsumableConsumer component3 = src_id.GetComponent <ConsumableConsumer>(); if (component3.forbiddenTags != null) { dest_id.forbiddenTags = new List <Tag>(component3.forbiddenTags); } MinionResume component4 = src_id.GetComponent <MinionResume>(); dest_id.MasteryBySkillID = component4.MasteryBySkillID; dest_id.AptitudeBySkillGroup = component4.AptitudeBySkillGroup; dest_id.TotalExperienceGained = component4.TotalExperienceGained; dest_id.currentHat = component4.CurrentHat; dest_id.targetHat = component4.TargetHat; ChoreConsumer component5 = src_id.GetComponent <ChoreConsumer>(); dest_id.choreGroupPriorities = component5.GetChoreGroupPriorities(); AttributeLevels component6 = src_id.GetComponent <AttributeLevels>(); component6.OnSerializing(); dest_id.attributeLevels = new List <AttributeLevels.LevelSaveLoad>(component6.SaveLoadLevels); StoreModifiers(src_id, dest_id); Schedulable component7 = src_id.GetComponent <Schedulable>(); Schedule schedule = component7.GetSchedule(); if (schedule != null) { schedule.Unassign(component7); Schedulable component8 = dest_id.GetComponent <Schedulable>(); schedule.Assign(component8); } }
private void OnSortClicked(object widget_go_obj) { GameObject widget_go = widget_go_obj as GameObject; PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(widget_go) as PrioritizationGroupTableColumn; ChoreGroup chore_group = prioritizationGroupTableColumn.userData as ChoreGroup; if (active_sort_column == prioritizationGroupTableColumn) { sort_is_reversed = !sort_is_reversed; } active_sort_column = prioritizationGroupTableColumn; active_sort_method = delegate(IAssignableIdentity a, IAssignableIdentity b) { MinionIdentity minionIdentity = a as MinionIdentity; MinionIdentity minionIdentity2 = b as MinionIdentity; if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null && (UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null) { return(0); } if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null) { return(-1); } if ((UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null) { return(1); } ChoreConsumer component = minionIdentity.GetComponent <ChoreConsumer>(); ChoreConsumer component2 = minionIdentity2.GetComponent <ChoreConsumer>(); if (component.IsChoreGroupDisabled(chore_group)) { return(1); } if (component2.IsChoreGroupDisabled(chore_group)) { return(-1); } int personalPriority = component.GetPersonalPriority(chore_group); int personalPriority2 = component2.GetPersonalPriority(chore_group); if (personalPriority == personalPriority2) { return(minionIdentity.name.CompareTo(minionIdentity2.name)); } return(personalPriority2 - personalPriority); }; SortRows(); }
public static void AddCreatureBrain(GameObject prefab, ChoreTable.Builder chore_table, Tag species, string symbol_prefix) { CreatureBrain creatureBrain = prefab.AddOrGet <CreatureBrain>(); creatureBrain.species = species; creatureBrain.symbolPrefix = symbol_prefix; ChoreConsumer chore_consumer = prefab.AddOrGet <ChoreConsumer>(); chore_consumer.choreTable = chore_table.CreateTable(); KPrefabID kPrefabID = prefab.AddOrGet <KPrefabID>(); kPrefabID.AddTag(GameTags.CreatureBrain, false); kPrefabID.instantiateFn += delegate(GameObject go) { go.GetComponent <ChoreConsumer>().choreTable = chore_consumer.choreTable; }; }
public void ReservePickupables() { ChoreConsumer consumer = base.sm.fetcher.Get <ChoreConsumer>(base.smi); float num = fetchAmountRequested; foreach (Pickupable fetchable in fetchables) { if (num <= 0f) { break; } float num2 = Math.Min(num, fetchable.UnreservedAmount); num -= num2; Reservation item = new Reservation(consumer, fetchable, num2); reservations.Add(item); } }
private static ChoreGroup BestPriorityGroup(Chore.Precondition.Context context, ChoreConsumer choreConsumer) { ChoreGroup choreGroup = null; if (context.chore.choreType.groups.Length > 0) { choreGroup = context.chore.choreType.groups[0]; for (int i = 1; i < context.chore.choreType.groups.Length; i++) { if (choreConsumer.GetPersonalPriority(choreGroup) < choreConsumer.GetPersonalPriority(context.chore.choreType.groups[i])) { choreGroup = context.chore.choreType.groups[i]; } } } return(choreGroup); }
private HierarchyReferences PriorityGroupForPriority(ChoreConsumer choreConsumer, Chore chore) { foreach (Tuple <PriorityScreen.PriorityClass, int, HierarchyReferences> priorityGroup in priorityGroups) { if (priorityGroup.first == chore.masterPriority.priority_class) { if (chore.masterPriority.priority_class != 0) { return(priorityGroup.third); } if (priorityGroup.second == choreConsumer.GetPersonalPriority(chore.choreType)) { return(priorityGroup.third); } } } return(null); }
protected override void OnSpawn() { base.OnSpawn(); ChoreConsumer component = GetComponent <ChoreConsumer>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { Subscribe(1623392196, OnDeathDelegate); Subscribe(-1506069671, OnAttachFollowCamDelegate); Subscribe(-485480405, OnDetachFollowCamDelegate); Subscribe(-1988963660, OnBeginChoreDelegate); AmountInstance amountInstance = this.GetAmounts().Get("Calories"); amountInstance.OnMaxValueReached = (System.Action)Delegate.Combine(amountInstance.OnMaxValueReached, new System.Action(OnMaxCaloriesReached)); Vector3 position = base.transform.GetPosition(); position.z = Grid.GetLayerZ(Grid.SceneLayer.Move); base.transform.SetPosition(position); base.gameObject.layer = LayerMask.NameToLayer("Default"); SetupDependentAttribute(Db.Get().Attributes.CarryAmount, Db.Get().AttributeConverters.CarryAmountFromStrength); } }
protected override void OnShow(bool show) { base.OnShow(show); refreshHandle.ClearScheduler(); if (!show) { if (useOffscreenIndicators) { foreach (GameObject choreTarget in choreTargets) { OffscreenIndicator.Instance.DeactivateIndicator(choreTarget); } } } else if (!((UnityEngine.Object)DetailsScreen.Instance.target == (UnityEngine.Object)null)) { choreConsumer = DetailsScreen.Instance.target.GetComponent <ChoreConsumer>(); PopulateElements(null); } }
public ChoreConsumerState(ChoreConsumer consumer) { this.consumer = consumer; navigator = consumer.GetComponent <Navigator>(); prefabid = consumer.GetComponent <KPrefabID>(); ownable = consumer.GetComponent <Ownable>(); gameObject = consumer.gameObject; solidTransferArm = consumer.GetComponent <SolidTransferArm>(); hasSolidTransferArm = ((Object)solidTransferArm != (Object)null); resume = consumer.GetComponent <MinionResume>(); choreDriver = consumer.GetComponent <ChoreDriver>(); schedulable = consumer.GetComponent <Schedulable>(); traits = consumer.GetComponent <Traits>(); choreProvider = consumer.GetComponent <ChoreProvider>(); MinionIdentity component = consumer.GetComponent <MinionIdentity>(); if ((Object)component != (Object)null) { if (component.assignableProxy == null) { component.assignableProxy = MinionAssignablesProxy.InitAssignableProxy(component.assignableProxy, component); } assignables = component.GetSoleOwner(); equipment = component.GetEquipment(); } else { assignables = consumer.GetComponent <Assignables>(); equipment = consumer.GetComponent <Equipment>(); } storage = consumer.GetComponent <Storage>(); consumableConsumer = consumer.GetComponent <ConsumableConsumer>(); worker = consumer.GetComponent <Worker>(); selectable = consumer.GetComponent <KSelectable>(); if ((Object)schedulable != (Object)null) { int blockIdx = Schedule.GetBlockIdx(); scheduleBlock = schedulable.GetSchedule().GetBlock(blockIdx); } }
/// Modifies critters as they are loaded /// missing parameters: is_baby, override_prefix, lifespan, diet_list /// babyId: only reveals material, actually object is defined in egg public static void PatchCritters(KPrefabID prefab, GameObject critter) { CritterContainer setting = CustomizeCritterState.StateManager.State.critter_settings.Find(s => s.id == critter.name); if (setting == null) { return; } Debug.Log("DEBUG HELLO 1"); if (setting.name != null) { prefab.PrefabTag = TagManager.Create(setting.id, setting.name); critter.GetComponent <KSelectable>()?.SetName(setting.name); critter.AddOrGet <DecorProvider>().overrideName = setting.name; } Debug.Log("DEBUG HELLO 2"); if (setting.desc != null) { critter.AddOrGet <InfoDescription>().description = setting.desc; } Debug.Log("DEBUG HELLO 3"); if (setting.anim_file != null) { KBatchedAnimController kbatchedAnimController = critter.AddOrGet <KBatchedAnimController>(); kbatchedAnimController.AnimFiles = new KAnimFile[] { Assets.GetAnim(setting.anim_file) }; //kbatchedAnimController.sceneLayer = sceneLayer; //kbatchedAnimController.initialAnim = initialAnim; } Debug.Log("DEBUG HELLO 4"); if (setting.is_baby != null) { Debug.Log(setting.id + ".is_baby: This cannot be changed on existing critters."); } Debug.Log("DEBUG HELLO 5"); if (setting.traitId != null) { Modifiers modifiers = critter.AddOrGet <Modifiers>(); if (setting.traitId != "") { modifiers.initialTraits = new string[] { setting.traitId } } ; else { modifiers.initialTraits = null; } //modifiers.initialAmounts.Add(Db.Get().Amounts.HitPoints.Id); } Debug.Log("DEBUG HELLO 6"); if (setting.override_prefix != null) { Debug.Log(setting.id + ".override_prefix: This cannot be changed on existing critters."); } Debug.Log("DEBUG HELLO 7"); if (setting.space_requirement != null) { critter.AddOrGetDef <OvercrowdingMonitor.Def>().spaceRequiredPerCreature = setting.space_requirement.Value; } Debug.Log("DEBUG HELLO 8"); if (setting.lifespan != null) { Debug.Log(setting.id + ".lifespan: This value is not read from the game. It exists only as artifact. Use traits instead!"); //trait.Add(new AttributeModifier(Db.Get().Amounts.Age.maxAttribute.Id, 150f, name, false, false, true)); } Debug.Log("DEBUG HELLO 9"); if (setting.mass != null) { critter.AddOrGet <PrimaryElement>().Mass = setting.mass.Value; } Debug.Log("DEBUG HELLO 10"); if (setting.width != null || setting.height != null) { float width = setting.width ?? 1f; float height = setting.height ?? 1f; KBoxCollider2D kboxCollider2D = critter.AddOrGet <KBoxCollider2D>(); kboxCollider2D.size = new Vector2f(width, height); float num = 0.5f * (float)((width + 1) % 2); kboxCollider2D.offset = new Vector2f(num, (float)height / 2f); critter.GetComponent <KBatchedAnimController>().Offset = new Vector3(num, 0f, 0f); critter.AddOrGet <OccupyArea>().OccupiedCellsOffsets = EntityTemplates.GenerateOffsets((int)Math.Round(width, 0), (int)Math.Round(height, 0)); } Debug.Log("DEBUG HELLO 11"); if (setting.decor != null) { DecorProvider decorProvider = critter.AddOrGet <DecorProvider>(); decorProvider.SetValues(setting.decor.Value); } Debug.Log("DEBUG HELLO 12"); if (setting.navGridName != null) { critter.AddOrGet <Navigator>().NavGridName = setting.navGridName; } Debug.Log("DEBUG HELLO 13"); if (setting.navi != null) { critter.AddOrGet <Navigator>().CurrentNavType = setting.navi.Value; } Debug.Log("DEBUG HELLO 14"); if (setting.moveSpeed != null) { critter.AddOrGet <Navigator>().defaultSpeed = setting.moveSpeed.Value; } Debug.Log("DEBUG HELLO 15"); if (setting.dropOnDeath != null) { critter.AddOrGet <Butcherable>().SetDrops(setting.dropOnDeath); } Debug.Log("DEBUG HELLO 16"); if (setting.canDrown != null) { if (setting.canDrown.Value) { critter.AddOrGet <DrowningMonitor>(); } else { critter.RemoveComponents <DrowningMonitor>(); } } Debug.Log("DEBUG HELLO 17"); if (setting.canCrushed != null) { if (setting.canCrushed.Value) { critter.AddOrGet <EntombVulnerable>(); } else { critter.RemoveComponents <EntombVulnerable>(); } } Debug.Log("DEBUG HELLO 18"); if (setting.tempLowDeath != null) { critter.AddOrGet <TemperatureVulnerable>().internalTemperatureLethal_Low = setting.tempLowDeath.Value; } Debug.Log("DEBUG HELLO 19"); if (setting.tempLowWarning != null) { critter.AddOrGet <TemperatureVulnerable>().internalTemperatureWarning_Low = setting.tempLowWarning.Value; } Debug.Log("DEBUG HELLO 20"); if (setting.tempHighWarning != null) { critter.AddOrGet <TemperatureVulnerable>().internalTemperatureWarning_High = setting.tempHighWarning.Value; } Debug.Log("DEBUG HELLO 21"); if (setting.tempHighDeath != null) { critter.AddOrGet <TemperatureVulnerable>().internalTemperatureLethal_High = setting.tempHighDeath.Value; } Debug.Log("DEBUG HELLO 22"); if (setting.tempBorn != null) { critter.AddOrGet <PrimaryElement>().Temperature = setting.tempBorn.Value; } Debug.Log("DEBUG HELLO 23"); if (setting.pickup_only_from_top != null) { critter.AddOrGet <Baggable>().mustStandOntopOfTrapForPickup = setting.pickup_only_from_top.Value; } Debug.Log("DEBUG HELLO 24"); if (setting.pickup_allow_mark != null) { critter.AddOrGet <Capturable>().allowCapture = setting.pickup_allow_mark.Value; } Debug.Log("DEBUG HELLO 25"); if (setting.pickup_use_gun != null) { critter.AddOrGet <Baggable>().useGunForPickup = setting.pickup_use_gun.Value; } Debug.Log("DEBUG HELLO 26"); if (setting.tags != null) { prefab.ProcessTags(setting.tags); } Debug.Log("DEBUG HELLO 27"); if (setting.species != null) { critter.AddOrGet <CreatureBrain>().species = setting.species; } Debug.Log("DEBUG HELLO 28"); if (setting.attackValue != null) { if (setting.attackValue.Value > 0f) { critter.AddWeapon(setting.attackValue.Value, setting.attackValue.Value, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f); } else { critter.RemoveComponents <Weapon>(); } } Debug.Log("DEBUG HELLO 29"); if (setting.chore_table != null) { ChoreConsumer chore_consumer = critter.AddOrGet <ChoreConsumer>(); chore_consumer.choreTable = setting.chore_table.CreateTable(); // prefab.instantiateFn += delegate(GameObject go) { go.GetComponent<ChoreConsumer>().choreTable = chore_consumer.choreTable; }; } Debug.Log("DEBUG HELLO 30"); if (setting.adultId != null) { critter.AddOrGetDef <BabyMonitor.Def>().adultPrefab = setting.adultId; } Debug.Log("DEBUG HELLO 31"); if (setting.dropOnMature != null) { critter.AddOrGetDef <BabyMonitor.Def>().onGrowDropID = setting.dropOnMature; } Debug.Log("DEBUG HELLO 32"); if (setting.fertility_cycles != null) { critter.AddOrGetDef <FertilityMonitor.Def>().baseFertileCycles = setting.fertility_cycles.Value; } Debug.Log("DEBUG HELLO 33"); if (setting.egg_chances != null) { critter.AddOrGetDef <FertilityMonitor.Def>().initialBreedingWeights = setting.egg_chances; } Debug.Log("DEBUG HELLO 34"); if (setting.is_ranchable != null) { if (setting.is_ranchable.Value) { critter.AddOrGetDef <RanchableMonitor.Def>(); } else { critter.RemoveDef <RanchableMonitor.Def>(); } } Debug.Log("DEBUG HELLO 35"); if (setting.calories_per_KG != null) { critter.AddOrGetDef <CreatureCalorieMonitor.Def>(); } Debug.Log("DEBUG HELLO 36"); if (setting.min_poop_KG != null) { critter.AddOrGetDef <CreatureCalorieMonitor.Def>().minPoopSizeInCalories = setting.min_poop_KG.Value * setting.calories_per_KG ?? 1f; } Debug.Log("DEBUG HELLO 37"); if (setting.diet_list != null) { //Diet diet = new Diet(setting.diet_list.ToArray()); //critter.AddOrGetDef<CreatureCalorieMonitor.Def>().diet = diet; //critter.AddOrGetDef<SolidConsumerMonitor.Def>().diet = diet; } Debug.Log("DEBUG HELLO 38"); if (setting.eggId != null) { critter.AddOrGetDef <FertilityMonitor.Def>().eggPrefab = setting.eggId; prefab.prefabSpawnFn += delegate(GameObject inst) { WorldInventory.Instance.Discover(setting.eggId.ToTag(), WorldInventory.GetCategoryForTags(egg_tags)); }; } Debug.Log("DEBUG HELLO 39"); if (setting.babyId != null) { prefab.prefabSpawnFn += delegate(GameObject inst) { WorldInventory.Instance.Discover(setting.babyId.ToTag(), WorldInventory.GetCategoryForTags(prefab.Tags)); }; } Debug.Log("DEBUG HELLO 40"); if (setting.light != null) { if (setting.light.color != Color.black) { Light2D light2D = critter.AddOrGet <Light2D>(); if (setting.light.color != null) { light2D.Color = setting.light.color.Value; } light2D.overlayColour = TUNING.LIGHT2D.LIGHTBUG_OVERLAYCOLOR; if (setting.light.range != null) { light2D.Range = setting.light.range.Value; } light2D.Angle = 0f; light2D.Direction = TUNING.LIGHT2D.LIGHTBUG_DIRECTION; light2D.Offset = TUNING.LIGHT2D.LIGHTBUG_OFFSET; light2D.shape = LightShape.Circle; light2D.drawOverlay = true; if (setting.light.lux != null) { light2D.Lux = setting.light.lux.Value; } critter.AddOrGet <LightSymbolTracker>().targetSymbol = "snapTo_light_locator"; critter.AddOrGetDef <CreatureLightToggleController.Def>(); } else { critter.RemoveComponents <Light2D>(); critter.RemoveComponents <LightSymbolTracker>(); critter.RemoveDef <CreatureLightToggleController.Def>(); } } Debug.Log("DEBUG HELLO 41"); if (setting.expulsion != null) //works also with gasses/liquids/solids { ElementDropperMonitor.Def def_morb = critter.AddOrGetDef <ElementDropperMonitor.Def>(); if (setting.expulsion.element != null) { def_morb.dirtyEmitElement = setting.expulsion.element.ToSimHash(); } if (setting.expulsion.probability != null) { def_morb.dirtyProbabilityPercent = setting.expulsion.probability.Value; } if (setting.expulsion.cellTargetMass != null) { def_morb.dirtyCellToTargetMass = setting.expulsion.cellTargetMass.Value; } if (setting.expulsion.massPerDirt != null) { def_morb.dirtyMassPerDirty = setting.expulsion.massPerDirt.Value; } if (setting.expulsion.onDeath != null) { def_morb.dirtyMassReleaseOnDeath = setting.expulsion.onDeath.Value; } if (setting.expulsion.diseaseId != null) { def_morb.emitDiseaseIdx = Db.Get().Diseases.GetIndex(setting.expulsion.diseaseId); } if (setting.expulsion.diseaseAmount != null) { def_morb.emitDiseasePerKg = setting.expulsion.diseaseAmount.Value; } } Debug.Log("DEBUG HELLO 42"); if (setting.scales != null) { ScaleGrowthMonitor.Def def_scale = critter.AddOrGetDef <ScaleGrowthMonitor.Def>(); if (setting.scales.growthRate != null) { def_scale.defaultGrowthRate = setting.scales.growthRate.Value; } if (setting.scales.mass != null) { def_scale.dropMass = setting.scales.mass.Value; } if (setting.scales.drop != null) { def_scale.itemDroppedOnShear = setting.scales.drop; } if (setting.scales.levelCount != null) { def_scale.levelCount = setting.scales.levelCount.Value; } if (setting.scales.atmosphere != null) { def_scale.targetAtmosphere = setting.scales.atmosphere.ToSimHash(); } } Debug.Log("DEBUG HELLO 43"); }
private void AddChoreEntry(Chore chore) { HierarchyReferences choreEntry = GetChoreEntry(GameUtil.GetChoreName(chore, null), chore.choreType, choreGroup.GetReference <RectTransform>("EntriesContainer")); FetchChore fetchChore = chore as FetchChore; ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate(); foreach (MinionIdentity item in Components.LiveMinionIdentities.Items) { pooledList.Clear(); ChoreConsumer component = item.GetComponent <ChoreConsumer>(); Chore.Precondition.Context context = default(Chore.Precondition.Context); ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = component.GetLastPreconditionSnapshot(); if (lastPreconditionSnapshot.doFailedContextsNeedSorting) { lastPreconditionSnapshot.failedContexts.Sort(); lastPreconditionSnapshot.doFailedContextsNeedSorting = false; } pooledList.AddRange(lastPreconditionSnapshot.failedContexts); pooledList.AddRange(lastPreconditionSnapshot.succeededContexts); int num = -1; int num2 = 0; for (int num3 = pooledList.Count - 1; num3 >= 0; num3--) { Chore.Precondition.Context context2 = pooledList[num3]; if ((UnityEngine.Object)context2.chore.driver != (UnityEngine.Object)null) { Chore.Precondition.Context context3 = pooledList[num3]; if ((UnityEngine.Object)context3.chore.driver != (UnityEngine.Object)component.choreDriver) { continue; } } bool flag = pooledList[num3].IsPotentialSuccess(); if (flag) { num2++; } Chore.Precondition.Context context4 = pooledList[num3]; FetchAreaChore fetchAreaChore = context4.chore as FetchAreaChore; Chore.Precondition.Context context5 = pooledList[num3]; if (context5.chore == chore || (fetchChore != null && fetchAreaChore != null && fetchAreaChore.smi.SameDestination(fetchChore))) { num = ((!flag) ? 2147483647 : num2); context = pooledList[num3]; break; } } if (num >= 0) { DupeEntryDatas.Add(new DupeEntryData { consumer = component, context = context, personalPriority = component.GetPersonalPriority(chore.choreType), rank = num }); } } pooledList.Recycle(); DupeEntryDatas.Sort(); foreach (DupeEntryData dupeEntryData in DupeEntryDatas) { GetDupeEntry(dupeEntryData, choreEntry.GetReference <RectTransform>("DupeContainer")); } DupeEntryDatas.Clear(); }
private void Refresh() { if (dirty) { int childCount = ColumnTitlesContainer.childCount; bool flag = false; bool flag2 = false; for (int i = 0; i < childCount; i++) { bool flag3 = false; bool flag4 = false; if (choreGroups.Count - 1 >= i) { ChoreGroup chore_group = choreGroups[i]; for (int j = 0; j < EntryObjects.Count; j++) { ChoreConsumer consumer = EntryObjects[j].GetComponent <CrewJobsEntry>().consumer; if (consumer.IsPermittedByTraits(chore_group)) { if (consumer.IsPermittedByUser(chore_group)) { flag3 = true; flag = true; } else { flag4 = true; flag2 = true; } } } if (flag3 && flag4) { EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.mixed; } else if (flag3) { EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.on; } else { EveryoneToggles[EveryoneToggles.ElementAt(i).Key] = everyoneToggleState.off; } Button componentInChildren = ColumnTitlesContainer.GetChild(i).GetComponentInChildren <Button>(); ImageToggleState component = componentInChildren.GetComponentsInChildren <Image>(true)[1].GetComponent <ImageToggleState>(); switch (EveryoneToggles[componentInChildren]) { case everyoneToggleState.off: component.SetDisabled(); break; case everyoneToggleState.mixed: component.SetInactive(); break; case everyoneToggleState.on: component.SetActive(); break; } } } if (flag && flag2) { EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.mixed); } else if (flag) { EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.on); } else if (flag2) { EveryoneAllTaskToggle = new KeyValuePair <Button, everyoneToggleState>(EveryoneAllTaskToggle.Key, everyoneToggleState.off); } ImageToggleState component2 = EveryoneAllTaskToggle.Key.GetComponentsInChildren <Image>(true)[1].GetComponent <ImageToggleState>(); switch (EveryoneAllTaskToggle.Value) { case everyoneToggleState.off: component2.SetDisabled(); break; case everyoneToggleState.mixed: component2.SetInactive(); break; case everyoneToggleState.on: component2.SetActive(); break; } Vector2 sizeDelta = EntriesPanelTransform.rectTransform().sizeDelta; screenWidth = sizeDelta.x; ScrollRectTransform.GetComponent <LayoutElement>().minWidth = screenWidth; float num = 31f; GetComponent <LayoutElement>().minWidth = screenWidth + num; dirty = false; } }
private static void CopyMinion(StoredMinionIdentity src_id, MinionIdentity dest_id) { dest_id.SetName(src_id.storedName); dest_id.nameStringKey = src_id.nameStringKey; dest_id.gender = src_id.gender; dest_id.genderStringKey = src_id.genderStringKey; dest_id.arrivalTime = src_id.arrivalTime; dest_id.voiceIdx = src_id.voiceIdx; dest_id.bodyData = src_id.bodyData; if (src_id.traitIDs != null) { Traits component = dest_id.GetComponent <Traits>(); component.SetTraitIds(src_id.traitIDs); } if (src_id.accessories != null) { Accessorizer component2 = dest_id.GetComponent <Accessorizer>(); component2.SetAccessories(src_id.accessories); } ConsumableConsumer component3 = dest_id.GetComponent <ConsumableConsumer>(); if (src_id.forbiddenTags != null) { component3.forbiddenTags = src_id.forbiddenTags.ToArray(); } if (src_id.MasteryBySkillID != null) { MinionResume component4 = dest_id.GetComponent <MinionResume>(); component4.RestoreResume(src_id.MasteryBySkillID, src_id.AptitudeBySkillGroup, src_id.TotalExperienceGained); component4.SetHats(src_id.currentHat, src_id.targetHat); } if (src_id.choreGroupPriorities != null) { ChoreConsumer component5 = dest_id.GetComponent <ChoreConsumer>(); component5.SetChoreGroupPriorities(src_id.choreGroupPriorities); } AttributeLevels component6 = dest_id.GetComponent <AttributeLevels>(); if (src_id.attributeLevels != null) { component6.SaveLoadLevels = src_id.attributeLevels.ToArray(); component6.OnDeserialized(); } dest_id.GetComponent <Accessorizer>().ApplyAccessories(); dest_id.assignableProxy = new Ref <MinionAssignablesProxy>(); dest_id.assignableProxy.Set(src_id.assignableProxy.Get()); dest_id.assignableProxy.Get().SetTarget(dest_id, dest_id.gameObject); Equipment equipment = dest_id.GetEquipment(); foreach (AssignableSlotInstance slot in equipment.Slots) { Equippable equippable = slot.assignable as Equippable; if ((UnityEngine.Object)equippable != (UnityEngine.Object)null) { equipment.Equip(equippable); } } Schedulable component7 = src_id.GetComponent <Schedulable>(); Schedule schedule = component7.GetSchedule(); if (schedule != null) { schedule.Unassign(component7); Schedulable component8 = dest_id.GetComponent <Schedulable>(); schedule.Assign(component8); } }
private void PopulateElements(object data = null) { refreshHandle.ClearScheduler(); refreshHandle = UIScheduler.Instance.Schedule("RefreshToDoList", 0.1f, PopulateElements, null, null); ListPool <Chore.Precondition.Context, BuildingChoresPanel> .PooledList pooledList = ListPool <Chore.Precondition.Context, BuildingChoresPanel> .Allocate(); ChoreConsumer.PreconditionSnapshot lastPreconditionSnapshot = choreConsumer.GetLastPreconditionSnapshot(); if (lastPreconditionSnapshot.doFailedContextsNeedSorting) { lastPreconditionSnapshot.failedContexts.Sort(); lastPreconditionSnapshot.doFailedContextsNeedSorting = false; } pooledList.AddRange(lastPreconditionSnapshot.failedContexts); pooledList.AddRange(lastPreconditionSnapshot.succeededContexts); Chore.Precondition.Context choreB = default(Chore.Precondition.Context); MinionTodoChoreEntry minionTodoChoreEntry = null; int num = 0; Schedulable component = DetailsScreen.Instance.target.GetComponent <Schedulable>(); string arg = string.Empty; Schedule schedule = component.GetSchedule(); if (schedule != null) { ScheduleBlock block = schedule.GetBlock(Schedule.GetBlockIdx()); arg = block.name; } currentScheduleBlockLabel.SetText(string.Format(UI.UISIDESCREENS.MINIONTODOSIDESCREEN.CURRENT_SCHEDULE_BLOCK, arg)); choreTargets.Clear(); bool flag = false; activeChoreEntries = 0; for (int num2 = pooledList.Count - 1; num2 >= 0; num2--) { Chore.Precondition.Context context = pooledList[num2]; if (context.chore != null) { Chore.Precondition.Context context2 = pooledList[num2]; if (!context2.chore.target.isNull) { Chore.Precondition.Context context3 = pooledList[num2]; if (!((UnityEngine.Object)context3.chore.target.gameObject == (UnityEngine.Object)null) && pooledList[num2].IsPotentialSuccess()) { Chore.Precondition.Context context4 = pooledList[num2]; if ((UnityEngine.Object)context4.chore.driver == (UnityEngine.Object)choreConsumer.choreDriver) { currentTask.Apply(pooledList[num2]); minionTodoChoreEntry = currentTask; choreB = pooledList[num2]; num = 0; flag = true; } else if (!flag && activeChoreEntries != 0 && GameUtil.AreChoresUIMergeable(pooledList[num2], choreB)) { num++; minionTodoChoreEntry.SetMoreAmount(num); } else { ChoreConsumer obj = choreConsumer; Chore.Precondition.Context context5 = pooledList[num2]; HierarchyReferences hierarchyReferences = PriorityGroupForPriority(obj, context5.chore); MinionTodoChoreEntry choreEntry = GetChoreEntry(hierarchyReferences.GetReference <RectTransform>("EntriesContainer")); choreEntry.Apply(pooledList[num2]); minionTodoChoreEntry = choreEntry; choreB = pooledList[num2]; num = 0; flag = false; } } } } } pooledList.Recycle(); for (int num3 = choreEntries.Count - 1; num3 >= activeChoreEntries; num3--) { choreEntries[num3].gameObject.SetActive(false); } foreach (Tuple <PriorityScreen.PriorityClass, int, HierarchyReferences> priorityGroup in priorityGroups) { RectTransform reference = priorityGroup.third.GetReference <RectTransform>("EntriesContainer"); priorityGroup.third.gameObject.SetActive(reference.childCount > 0); } }