Beispiel #1
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        Door door = go.AddOrGet <Door>();

        door.hasComplexUserControls    = true;
        door.unpoweredAnimSpeed        = 0.65f;
        door.poweredAnimSpeed          = 5f;
        door.doorClosingSoundEventName = "MechanizedAirlock_closing";
        door.doorOpeningSoundEventName = "MechanizedAirlock_opening";
        go.AddOrGet <AccessControl>();
        go.AddOrGet <KBoxCollider2D>();
        Prioritizable.AddRef(go);
        Workable workable = go.AddOrGet <Workable>();

        workable.workTime = 5f;
        GeneratedBuildings.RegisterLogicPorts(go, DoorConfig.INPUT_PORTS);
        Object.DestroyImmediate(go.GetComponent <BuildingEnabledButton>());
        BuildingTemplates.DoPostConfigure(go);
        AccessControl component = go.GetComponent <AccessControl>();

        component.controlEnabled = true;
        KBatchedAnimController component2 = go.GetComponent <KBatchedAnimController>();

        component2.initialAnim = "closed";
    }
        // Transfer a fraction of consumed germs to the worker and finish the chore
        public void FinishGermyWork(Workable work, Worker worker)
        {
            if (work == null)
            {
                throw new ArgumentNullException("work");
            }
            if (worker == null)
            {
                throw new ArgumentNullException("worker");
            }
            var obj = worker.gameObject;

            if (germsConsumed.TryGetValue(work, out SimUtil.DiseaseInfo germs) && obj != null)
            {
                // Less than 1 germ = no transfer
                int count = germs.count;
                var dupe  = obj.GetComponent <PrimaryElement>();
                if (count > 0)
                {
                    dupe.AddDisease(germs.idx, Mathf.RoundToInt(GermExposureTuning.
                                                                SINK_GERMS_TO_TRANSFER * count), "GermySinkManager.FinishGermyWork");
                    obj.AddOrGet <WashCooldownComponent>().OnWashComplete();
                }
            }
        }
Beispiel #3
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        GeneratedBuildings.RegisterLogicPorts(go, DoorConfig.INPUT_PORTS_N1_0);
        Door door = go.AddOrGet <Door>();

        door.unpoweredAnimSpeed        = 0.01f;
        door.poweredAnimSpeed          = 0.1f;
        door.hasComplexUserControls    = true;
        door.allowAutoControl          = false;
        door.doorOpeningSoundEventName = "BunkerDoor_opening";
        door.doorClosingSoundEventName = "BunkerDoor_closing";
        door.verticalOrientation       = Orientation.R90;
        Workable workable = go.AddOrGet <Workable>();

        workable.workTime = 3f;
        KBatchedAnimController component = go.GetComponent <KBatchedAnimController>();

        component.initialAnim    = "closed";
        component.visibilityType = KAnimControllerBase.VisibilityType.OffscreenUpdate;
        go.AddOrGet <ZoneTile>();
        go.AddOrGet <KBoxCollider2D>();
        Prioritizable.AddRef(go);
        Object.DestroyImmediate(go.GetComponent <BuildingEnabledButton>());
        KPrefabID component2 = go.GetComponent <KPrefabID>();

        component2.AddTag(GameTags.Bunker, false);
    }
    public override void DoPostConfigureComplete(GameObject go)
    {
        Door door = go.AddOrGet <Door>();

        door.unpoweredAnimSpeed        = 1f;
        door.doorType                  = Door.DoorType.Internal;
        door.doorOpeningSoundEventName = "Open_DoorInternal";
        door.doorClosingSoundEventName = "Close_DoorInternal";
        AccessControl accessControl = go.AddOrGet <AccessControl>();

        accessControl.controlEnabled = true;
        CopyBuildingSettings copyBuildingSettings = go.AddOrGet <CopyBuildingSettings>();

        copyBuildingSettings.copyGroupTag = GameTags.Door;
        Workable workable = go.AddOrGet <Workable>();

        workable.workTime = 3f;
        KBatchedAnimController component = go.GetComponent <KBatchedAnimController>();

        component.initialAnim = "closed";
        go.AddOrGet <ZoneTile>();
        go.AddOrGet <KBoxCollider2D>();
        Prioritizable.AddRef(go);
        GeneratedBuildings.RegisterLogicPorts(go, INPUT_PORTS_0_0);
        Object.DestroyImmediate(go.GetComponent <BuildingEnabledButton>());
    }
        public override void DoPostConfigureComplete(GameObject go)
        {
            Door door = go.AddOrGet <Door>();

            door.hasComplexUserControls    = true;
            door.unpoweredAnimSpeed        = 0.9f;
            door.poweredAnimSpeed          = 6f;
            door.doorClosingSoundEventName = "MechanizedAirlock_closing";
            door.doorOpeningSoundEventName = "MechanizedAirlock_opening";
            go.AddOrGet <ZoneTile>();
            go.AddOrGet <AccessControl>();
            go.AddOrGet <KBoxCollider2D>();
            Prioritizable.AddRef(go);
            CopyBuildingSettings copyBuildingSettings = go.AddOrGet <CopyBuildingSettings>();

            copyBuildingSettings.copyGroupTag = GameTags.Door;
            Workable workable = go.AddOrGet <Workable>();

            workable.workTime = 10f;
            UnityEngine.Object.DestroyImmediate(go.GetComponent <BuildingEnabledButton>());
            AccessControl component = go.GetComponent <AccessControl>();

            component.controlEnabled = true;
            KBatchedAnimController component2 = go.GetComponent <KBatchedAnimController>();

            component2.initialAnim = "closed";
        }
Beispiel #6
0
            public static void Postfix(Workable __instance)
            {
                try
                {
                    if (Game.Instance == null)
                    {
                        return;
                    }

                    var door = __instance.GetComponent <Door>();

                    if (door != null && !State.DoorIcons.ContainsKey(door))
                    {
                        var icon = IconManager.CreateIcon(door);

                        State.DoorIcons.Add
                        (
                            door,
                            icon
                        );

                        __instance.gameObject.Subscribe((int)GameHashes.LogicEvent, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.DoorStateChanged, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.CopySettings, data => IconManager.UpdateIcon(door));
                        __instance.gameObject.Subscribe((int)GameHashes.DoorControlStateChanged, data => IconManager.UpdateIcon(door));
                    }
                }
                catch (Exception e)
                {
                    State.Common.Logger.LogOnce("Error while trying to create door icon", e);
                }
            }
Beispiel #7
0
    public GameObject CreatePrefab()
    {
        GameObject     gameObject = EntityTemplates.CreatePlacedEntity("SetLocker", STRINGS.BUILDINGS.PREFABS.SETLOCKER.NAME, STRINGS.BUILDINGS.PREFABS.SETLOCKER.DESC, 100f, Assets.GetAnim("setpiece_locker_kanim"), "on", Grid.SceneLayer.Building, 1, 2, TUNING.BUILDINGS.DECOR.BONUS.TIER0, NOISE_POLLUTION.NOISY.TIER0, SimHashes.Creature, null, 293f);
        PrimaryElement component  = gameObject.GetComponent <PrimaryElement>();

        component.SetElement(SimHashes.Unobtanium);
        component.Temperature = 294.15f;
        Workable workable = gameObject.AddOrGet <Workable>();

        workable.synchronizeAnims    = false;
        workable.resetProgressOnStop = true;
        SetLocker setLocker = gameObject.AddOrGet <SetLocker>();

        setLocker.overrideAnim          = "anim_interacts_clothingfactory_kanim";
        setLocker.dropOffset            = new Vector2I(0, 1);
        setLocker.possible_contents_ids = new string[3]
        {
            "Warm_Vest",
            "Cool_Vest",
            "Funky_Vest"
        };
        gameObject.AddOrGet <LoreBearer>();
        OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>();

        occupyArea.objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        return(gameObject);
    }
Beispiel #8
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3 position  = behaviour.GetComponent <Transform>().GetPosition();
        Worker  component = behaviour.GetComponent <Worker>();

        if ((UnityEngine.Object)component == (UnityEngine.Object)null)
        {
            SoundEvent.PlayOneShot(GlobalAssets.GetSound("Building_Dmg_Metal", false), position);
        }
        else
        {
            Workable workable = component.workable;
            if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
            {
                Building component2 = workable.GetComponent <Building>();
                if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                {
                    BuildingDef def   = component2.Def;
                    string      name  = StringFormatter.Combine(base.name, "_", def.AudioCategory);
                    string      sound = GlobalAssets.GetSound(name, false);
                    if (sound == null)
                    {
                        name  = "Building_Dmg_Metal";
                        sound = GlobalAssets.GetSound(name, false);
                    }
                    if (sound != null)
                    {
                        SoundEvent.PlayOneShot(sound, position);
                    }
                }
            }
        }
    }
Beispiel #9
0
 public static void Postfix(ref Workable __instance, ref float __result)
 {
     if (__instance is Diggable)
     {
         __result *= Mathf.Clamp(1200f / Grid.Mass[Grid.PosToCell(__instance)], 0.25f, 10f);
     }
 }
    protected override void OnSpawn()
    {
        base.OnSpawn();
        Prioritizable.AddRef(base.gameObject);
        if (configuration == null || configuration.typeId == HashedString.Invalid)
        {
            configuration = GetComponent <GeyserConfigurator>().MakeConfiguration();
        }
        emitter.emitRange   = 2;
        emitter.maxPressure = configuration.GetMaxPressure();
        ElementEmitter elementEmitter       = emitter;
        float          emitRate             = configuration.GetEmitRate();
        SimHashes      element              = configuration.GetElement();
        float          temperature          = configuration.GetTemperature();
        float          outputElementOffsetx = (float)outputOffset.x;
        float          outputElementOffsety = (float)outputOffset.y;

        elementEmitter.outputElement = new ElementConverter.OutputElement(emitRate, element, temperature, false, false, outputElementOffsetx, outputElementOffsety, 1f, configuration.GetDiseaseIdx(), Mathf.RoundToInt((float)configuration.GetDiseaseCount() * configuration.GetEmitRate()));
        base.smi.StartSM();
        Workable component = GetComponent <Studyable>();

        if ((Object)component != (Object)null)
        {
            component.alwaysShowProgressBar = true;
        }
    }
        // Accumulate how many germs remain
        public void SinkWorkTick(Workable work, float dt)
        {
            if (work == null)
            {
                throw new ArgumentNullException("work");
            }
            var obj = work.gameObject;

            if (germsConsumed.TryGetValue(work, out SimUtil.DiseaseInfo germs) && obj != null)
            {
                var sanitizer = obj.GetComponent <HandSanitizer>();
                var storage   = obj.GetComponent <Storage>();
                // Only if a hand sanitizer with available contents
                if (sanitizer != null && storage != null)
                {
                    float time = work.workTime, qty = sanitizer.massConsumedPerUse * dt /
                                                      time;
                    GetGermsInStorage(storage, ElementLoader.FindElementByHash(sanitizer.
                                                                               consumedElement).tag, qty, out SimUtil.DiseaseInfo itemGerm);
                    // Only transfer if disease matches and germ count is nonzero
                    if (itemGerm.count > 0 && (germs.count < 1 || germs.idx == itemGerm.idx))
                    {
                        germs.count += itemGerm.count;
                        germs.idx    = itemGerm.idx;
                        // It is a struct, must store it back
                        germsConsumed[work] = germs;
                    }
                }
            }
        }
 public Instance(Workable workable, Worker worker, HashedString context, GameObject hit_effect)
     : base(worker)
 {
     hitEffectPrefab = hit_effect;
     worker.GetComponent <AnimEventHandler>().SetContext(context);
     base.sm.worker.Set(worker, base.smi);
     base.sm.workable.Set(workable, base.smi);
     anims = GetAnimationStrings(workable, worker, "dig");
 }
            private static void Postfix(Workable __instance, ref float __result)
            {
                var tinkerableWorkable = __instance.GetComponent <TinkerableWorkable>();

                if (tinkerableWorkable != null)
                {
                    __result *= tinkerableWorkable.GetCraftingSpeedMultiplier();
                }
            }
Beispiel #14
0
        private static void Postfix(Workable __instance, Worker worker, ref float __result)
        {
            if (!WorkableMultipliersConfig.Instance.Enabled)
            {
                return;
            }
            //Debug.Log(" === WorkEditorMod_Constructable_GetEfficiencyMultiplier === " + __instance.GetType().ToString());

            __result = WorkableMultipliersUtils.GetMultiplier("EfficiencyMultiplier", __result, __instance);
        }
Beispiel #15
0
        protected static void ModifyChore(Workable instance, Chore chore, Func <Workable, bool> isEndlessWorking)
        {
            var precondition = new Chore.Precondition()
            {
                id          = "RequireAttributeRange",
                fn          = delegate(ref Chore.Precondition.Context context, object data) { return(!isEndlessWorking(instance) || ShouldChoreBeWorked(context)); },
                description = DUPLICANTS.CHORES.PRECONDITIONS.REQUIRES_ATTRIBUTE_RANGE.DESCRIPTION
            };

            chore.AddPrecondition(precondition, null);
        }
    private Chore CreateChore(int i)
    {
        Workable          workable   = workables[i];
        ChoreType         relax      = Db.Get().ChoreTypes.Relax;
        Workable          target     = workable;
        ScheduleBlockType recreation = Db.Get().ScheduleBlockTypes.Recreation;
        Chore             chore      = new WorkChore <PhonoboxWorkable>(relax, target, null, true, null, null, OnSocialChoreEnd, false, recreation, false, true, null, false, true, false, PriorityScreen.PriorityClass.high, 5, false, true);

        chore.AddPrecondition(ChorePreconditions.instance.CanDoWorkerPrioritizable, workable);
        return(chore);
    }
Beispiel #17
0
    public string GetHitAnim()
    {
        Workable component = base.smi.sm.attackTarget.Get(base.smi).gameObject.GetComponent <Workable>();

        if ((bool)component)
        {
            string text = MultitoolController.GetAnimationStrings(component, gameObject.GetComponent <Worker>(), "hit")[1];
            return(text.Replace("_loop", string.Empty));
        }
        return("hit");
    }
            private Chore CreateChore(StatesInstance smi)
            {
                Workable component = smi.master.GetComponent <ChampagneFillerWorkable>();
                Chore    chore     = new WorkChore <ChampagneFillerWorkable>(Db.Get().ChoreTypes.Relax, component,
                                                                             null, true, null, null, null, false,
                                                                             Db.Get().ScheduleBlockTypes.Recreation, false, true, null, false, true, false,
                                                                             PriorityScreen.PriorityClass.high, 5, false, true);

                chore.AddPrecondition(ChorePreconditions.instance.CanDoWorkerPrioritizable, component);
                return(chore);
            }
Beispiel #19
0
        private Chore CreateChore(StatesInstance smi)
        {
            Workable          component  = smi.master.GetComponent <EspressoMachineWorkable>();
            ChoreType         relax      = Db.Get().ChoreTypes.Relax;
            Workable          target     = component;
            ScheduleBlockType recreation = Db.Get().ScheduleBlockTypes.Recreation;
            Chore             chore      = new WorkChore <EspressoMachineWorkable>(relax, target, null, true, null, null, null, false, recreation, false, true, null, false, true, false, PriorityScreen.PriorityClass.high, 5, false, true);

            chore.AddPrecondition(ChorePreconditions.instance.CanDoWorkerPrioritizable, component);
            return(chore);
        }
Beispiel #20
0
    public override void OnPlay(AnimEventManager.EventPlayerData behaviour)
    {
        if (!string.IsNullOrEmpty(base.sound) && SoundEvent.ShouldPlaySound(behaviour.controller, base.sound, base.looping, isDynamic))
        {
            int        num        = -1;
            GameObject gameObject = behaviour.controller.gameObject;
            if (counterModulus >= -1)
            {
                HandleVector <int> .Handle h = GameComps.WhiteBoards.GetHandle(gameObject);
                if (!h.IsValid())
                {
                    h = GameComps.WhiteBoards.Add(gameObject);
                }
                num = (GameComps.WhiteBoards.HasValue(h, base.soundHash) ? ((int)GameComps.WhiteBoards.GetValue(h, base.soundHash)) : 0);
                int num2 = (counterModulus != -1) ? ((num + 1) % counterModulus) : 0;
                GameComps.WhiteBoards.SetValue(h, base.soundHash, num2);
            }
            Vector3 position  = behaviour.GetComponent <Transform>().GetPosition();
            string  sound     = GlobalAssets.GetSound("Hammer_sculpture", false);
            Worker  component = behaviour.GetComponent <Worker>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                Workable workable = component.workable;
                if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
                {
                    Building component2 = workable.GetComponent <Building>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                    {
                        BuildingDef def = component2.Def;
                        switch (def.name)
                        {
                        case "MetalSculpture":
                            sound = GlobalAssets.GetSound("Hammer_sculpture_metal", false);
                            break;

                        case "MarbleSculpture":
                            sound = GlobalAssets.GetSound("Hammer_sculpture_marble", false);
                            break;
                        }
                    }
                }
            }
            EventInstance instance = SoundEvent.BeginOneShot(sound, position);
            if (instance.isValid())
            {
                if (num >= 0)
                {
                    instance.setParameterValue("eventCount", (float)num);
                }
                SoundEvent.EndOneShot(instance);
            }
        }
    }
Beispiel #21
0
            static void Postfix(Workable __instance)
            {
                requiresAttributeRange = new StatusItem("RequiresAttributeRange", "BUILDING", "", StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.None.ID)
                {
                    resolveStringCallback = (string str, object obj) =>
                    {
                        var minMax = ((int, int))obj;
                        return(str.Replace("{Attributes}", minMax.Item1 + " - " + minMax.Item2));
                    }
                };

                __instance.attributeExperienceMultiplier = GetMultiplier(__instance.gameObject);
            }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
        ValveBase valveBase = go.AddOrGet <ValveBase>();

        valveBase.conduitType = CONDUIT_TYPE;
        valveBase.maxFlow     = 10f;

        go.AddOrGet <Valve>();
        Workable workable = go.AddOrGet <Workable>();

        workable.workTime = 5f;
    }
Beispiel #23
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        Door door = go.AddOrGet <Door>();

        door.unpoweredAnimSpeed = 1f;
        door.doorType           = Door.DoorType.Internal;
        go.AddOrGet <ZoneTile>();
        go.AddOrGet <AccessControl>();
        Workable workable = go.AddOrGet <Workable>();

        workable.workTime = 3f;
        go.AddOrGet <KBoxCollider2D>();
        Prioritizable.AddRef(go);
        Object.DestroyImmediate(go.GetComponent <BuildingEnabledButton>());
    }
 // Starts a sink/shower work entry for germ tracking
 public void StartGermyWork(Workable work)
 {
     if (work == null)
     {
         throw new ArgumentNullException("work");
     }
     if (germsConsumed.ContainsKey(work))
     {
         // Be charitable and trash any germs from aborted chores
         germsConsumed[work] = new SimUtil.DiseaseInfo();
     }
     else
     {
         germsConsumed.Add(work, new SimUtil.DiseaseInfo());
     }
 }
Beispiel #25
0
 /// <summary>
 /// Applied before UpdateStatusItem runs.
 /// </summary>
 internal static bool Prefix(Workable __instance)
 {
     if (__instance.TryGetComponent(out KSelectable selectable))
     {
         var      working      = __instance.workingStatusItem;
         ref Guid statusHandle = ref __instance.workStatusItemHandle;
         selectable.RemoveStatusItem(statusHandle, false);
         if (__instance.worker == null)
         {
             UpdateStatusItem(__instance, selectable, ref statusHandle);
         }
         else if (working != null)
         {
             statusHandle = selectable.AddStatusItem(working, __instance);
         }
     }
 public void UpdateHitEffectTarget()
 {
     if (!((UnityEngine.Object)hitEffect == (UnityEngine.Object)null))
     {
         Workable         workable    = base.sm.workable.Get <Workable>(base.smi);
         Worker           worker      = base.sm.worker.Get <Worker>(base.smi);
         AnimEventHandler component   = worker.GetComponent <AnimEventHandler>();
         Vector3          targetPoint = workable.GetTargetPoint();
         worker.GetComponent <Facing>().Face(workable.transform.GetPosition());
         anims = GetAnimationStrings(workable, worker, "dig");
         PlayLoop();
         component.SetTargetPos(targetPoint);
         component.UpdateWorkTarget(workable.GetTargetPoint());
         hitEffect.transform.SetPosition(targetPoint);
     }
 }
Beispiel #27
0
        /// <summary>
        /// Marks the direction where a worker was standing.
        /// </summary>
        /// <param name="instance">The target workable.</param>
        /// <param name="worker">The Duplicant working the task.</param>
        private static void MarkDirection(Workable instance, Worker worker)
        {
            var inst = CleanDropManager.Instance;

            if (inst != null && worker != null)
            {
                int targetCell = instance.GetCell();
                inst[targetCell] = CleanDropManager.GetWorkerDirection(Grid.PosToCell(worker),
                                                                       targetCell);
#if DEBUG
                Grid.CellToXY(targetCell, out int x, out int y);
                PUtil.LogDebug("Mark workable {0} in cell ({1:D}, {2:D}) direction = {3}".F(
                                   instance.GetType().FullName, x, y, inst[targetCell]));
#endif
            }
        }
 public override void InitializeStates(out BaseState default_state)
 {
     default_state = nochore;
     saveHistory   = true;
     nochore.Update(delegate(StatesInstance smi, float dt)
     {
         if (smi.master.HasTag(GameTags.Minion) && !smi.master.HasTag(GameTags.Dead))
         {
             ReportManager.Instance.ReportValue(ReportManager.ReportType.WorkTime, dt, string.Format(UI.ENDOFDAYREPORT.NOTES.TIME_SPENT, DUPLICANTS.CHORES.THINKING.NAME), smi.master.GetProperName());
         }
     }, UpdateRate.SIM_200ms, false).ParamTransition(nextChore, haschore, (StatesInstance smi, Chore next_chore) => next_chore != null);
     haschore.Enter("BeginChore", delegate(StatesInstance smi)
     {
         smi.BeginChore();
     }).Update(delegate(StatesInstance smi, float dt)
     {
         if (smi.master.HasTag(GameTags.Minion) && !smi.master.HasTag(GameTags.Dead))
         {
             Chore chore = currentChore.Get(smi);
             if (chore != null)
             {
                 if (smi.master.GetComponent <Navigator>().IsMoving())
                 {
                     ReportManager.Instance.ReportValue(ReportManager.ReportType.TravelTime, dt, GameUtil.GetChoreName(chore, null), smi.master.GetProperName());
                 }
                 else
                 {
                     ReportManager.ReportType reportType = chore.GetReportType();
                     Workable workable = smi.master.GetComponent <Worker>().workable;
                     if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
                     {
                         ReportManager.ReportType reportType2 = workable.GetReportType();
                         if (reportType != reportType2)
                         {
                             reportType = reportType2;
                         }
                     }
                     ReportManager.Instance.ReportValue(reportType, dt, string.Format(UI.ENDOFDAYREPORT.NOTES.WORK_TIME, GameUtil.GetChoreName(chore, null)), smi.master.GetProperName());
                 }
             }
         }
     }, UpdateRate.SIM_200ms, false).Exit("EndChore", delegate(StatesInstance smi)
     {
         smi.EndChore("ChoreDriver.SignalStop");
     })
     .OnSignal(stop, nochore);
 }
	public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
	{
		GeneratedBuildings.MakeBuildingAlwaysOperational(go);
		BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
		ValveBase valveBase = go.AddOrGet<ValveBase>();
		valveBase.conduitType = ConduitType.Liquid;
		valveBase.maxFlow = 10f;
		valveBase.animFlowRanges = new ValveBase.AnimRangeInfo[3]
		{
			new ValveBase.AnimRangeInfo(3f, "lo"),
			new ValveBase.AnimRangeInfo(7f, "med"),
			new ValveBase.AnimRangeInfo(10f, "hi")
		};
		go.AddOrGet<Valve>();
		Workable workable = go.AddOrGet<Workable>();
		workable.workTime = 5f;
	}
Beispiel #30
0
        /// <summary>
        /// A non-mutating version of Navigator.GetNavigationCost that can be run on
        /// background threads.
        /// </summary>
        /// <param name="navigator">The navigator to calculate.</param>
        /// <param name="destination">The destination to find the cost.</param>
        /// <param name="cell">The workable's current cell.</param>
        /// <param name="cost">The location where the cost will be stored.</param>
        /// <returns>true if the table needs to be updated, or false otherwise.</returns>
        public static bool GetNavigationCostNU(this Navigator navigator, Workable destination,
                                               int cell, out int cost)
        {
            CellOffset[] offsets       = null;
            bool         update        = false;
            var          offsetTracker = destination.offsetTracker;

            if (offsetTracker != null && (offsets = offsetTracker.offsets) == null)
            {
                offsetTracker.UpdateOffsets(cell);
                offsets = offsetTracker.offsets;
                update  = offsetTracker.previousCell != cell;
            }
            cost = (offsets == null) ? navigator.GetNavigationCost(cell) : navigator.
                   GetNavigationCost(cell, offsets);
            return(update);
        }