private void OnCopySettings(object data)
        {
            GameObject             gameObject = (GameObject)data;
            CoalDeliveryController component  = gameObject.GetComponent <CoalDeliveryController>();

            if (component != null)
            {
                this.batteryRefillPercent = component.batteryRefillPercent;
                this.Sim1000ms(0);
            }
        }
Exemple #2
0
        public static void Apply(GameObject go)
        {
            EnergyGenerator  origEnergyGenerator  = go.GetComponent <EnergyGenerator>();
            Storage          storage              = go.GetComponent <Storage>();
            ManualDeliveryKG origManualDeliveryKG = go.GetComponent <ManualDeliveryKG>();

            if (storage.capacityKg == 20000)
            {
                // the storage haven't been set. The sliders rely on it for max value. Set it to the max storage from other components.
                storage.capacityKg = Mathf.Max(origManualDeliveryKG.capacity, origEnergyGenerator.formula.inputs[0].maxStoredMass);
            }

            CoalEnergyGenerator energyGenerator = go.AddOrGet <CoalEnergyGenerator>();

            energyGenerator.powerDistributionOrder = origEnergyGenerator.powerDistributionOrder;
            energyGenerator.hasMeter = true;
            energyGenerator.formula  = origEnergyGenerator.formula;

            CoalManualDeliveryKG manualDeliveryKG = go.AddOrGet <CoalManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag       = origManualDeliveryKG.requestedItemTag;
            manualDeliveryKG.ignoresOperationStatus = true;
            manualDeliveryKG.capacity   = origManualDeliveryKG.capacity;
            manualDeliveryKG.refillMass = origManualDeliveryKG.refillMass;
            manualDeliveryKG.choreTags  = new Tag[]
            {
                GameTags.ChoreTypes.Power
            };
            manualDeliveryKG.choreTypeIDHash = Db.Get().ChoreTypes.PowerFetch.IdHash;

            DualSlider dualSlider = go.AddOrGet <DualSlider>();

            dualSlider.fillUptoThreshold = manualDeliveryKG.capacity;
            dualSlider.refillThreshold   = manualDeliveryKG.refillMass;

            CoalDeliveryController controller = go.AddOrGet <CoalDeliveryController>();

            controller.batteryRefillPercent = 0.5f;

            AddStrings.AddString(manualDeliveryKG.RequestedItemTag.Name);

            UnityEngine.Object.DestroyImmediate(origEnergyGenerator);
            UnityEngine.Object.DestroyImmediate(origManualDeliveryKG);
        }
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery);
            CoalEnergyGenerator energyGenerator = go.AddOrGet <CoalEnergyGenerator>();

            energyGenerator.formula = EnergyGenerator.CreateSimpleFormula(SimHashes.Carbon.CreateTag(), 1f, 600f, SimHashes.Void, 0f, true);
            energyGenerator.powerDistributionOrder = 9;
            Storage storage = go.AddOrGet <Storage>();

            storage.capacityKg = 600f;
            go.AddOrGet <LoopingSounds>();
            Prioritizable.AddRef(go);
            CoalManualDeliveryKG manualDeliveryKG = go.AddOrGet <CoalManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag       = new Tag("Coal");
            manualDeliveryKG.ignoresOperationStatus = true;
            manualDeliveryKG.capacity   = storage.capacityKg;
            manualDeliveryKG.refillMass = 100f;
            manualDeliveryKG.choreTags  = new Tag[]
            {
                GameTags.ChoreTypes.Power
            };
            manualDeliveryKG.choreTypeIDHash = Db.Get().ChoreTypes.PowerFetch.IdHash;

            BuildingElementEmitter buildingElementEmitter = go.AddOrGet <BuildingElementEmitter>();

            buildingElementEmitter.emitRate       = 0.02f;
            buildingElementEmitter.temperature    = 310f;
            buildingElementEmitter.element        = SimHashes.CarbonDioxide;
            buildingElementEmitter.modifierOffset = new Vector2(1f, 2f);

            DualSlider dualSlider = go.AddOrGet <DualSlider>();

            dualSlider.fillUptoThreshold = manualDeliveryKG.capacity;
            dualSlider.refillThreshold   = manualDeliveryKG.refillMass;

            CoalDeliveryController controller = go.AddOrGet <CoalDeliveryController>();

            controller.batteryRefillPercent = 0.5f;

            Tinkerable.MakePowerTinkerable(go);
        }
        public static void Postfix(GameObject go)
        {
            EnergyGenerator  origEnergyGenerator  = go.GetComponent <EnergyGenerator>();
            Storage          storage              = go.GetComponent <Storage>();
            ManualDeliveryKG origManualDeliveryKG = go.GetComponent <ManualDeliveryKG>();

            CoalEnergyGenerator energyGenerator = go.AddOrGet <CoalEnergyGenerator>();

            energyGenerator.powerDistributionOrder = origEnergyGenerator.powerDistributionOrder;
            energyGenerator.hasMeter = true;
            energyGenerator.formula  = origEnergyGenerator.formula;

            CoalManualDeliveryKG manualDeliveryKG = go.AddOrGet <CoalManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag       = origManualDeliveryKG.requestedItemTag;
            manualDeliveryKG.ignoresOperationStatus = true;
            manualDeliveryKG.capacity   = origManualDeliveryKG.capacity;
            manualDeliveryKG.refillMass = origManualDeliveryKG.refillMass;
            manualDeliveryKG.choreTags  = new Tag[]
            {
                GameTags.ChoreTypes.Power
            };
            manualDeliveryKG.choreTypeIDHash = Db.Get().ChoreTypes.PowerFetch.IdHash;

            DualSlider dualSlider = go.AddOrGet <DualSlider>();

            dualSlider.fillUptoThreshold = manualDeliveryKG.capacity;
            dualSlider.refillThreshold   = manualDeliveryKG.refillMass;

            CoalDeliveryController controller = go.AddOrGet <CoalDeliveryController>();

            controller.batteryRefillPercent = 0.5f;

            AddStrings.AddString(manualDeliveryKG.RequestedItemTag.Name);

            UnityEngine.Object.DestroyImmediate(origEnergyGenerator);
            UnityEngine.Object.DestroyImmediate(origManualDeliveryKG);
        }