Exemplo n.º 1
0
        public override void Tick()
        {
            base.Tick();

            Boolean _PowerAvalable = false;

            //Check to prevent NullPointerExceptions
            if (shieldField != null)
            {
                //Disable shield when power goes off
                if (this.power != null)
                {
                    if (this.power.PowerOn)
                    {
                        _PowerAvalable = true;
                    }

                }
                //Do tick for the shield field
                shieldField.ShieldTick(_PowerAvalable, this.flag_direct, this.flag_indirect, this.flag_fireSupression, this.flag_InterceptDropPod, this.flag_shieldRepairMode);

                //Change power requirements depending on shield status
                switch (shieldField.status)
                {
                    //Disabled shield also requires power (to avoid flickering when thing increases power requirements because it gained power...)
                    case enumShieldStatus.Disabled:
                    case enumShieldStatus.Loading:
                        {
                            this.power.powerOutputInt = shieldPowerRequiredCharging;
                            break;
                        }
                    case enumShieldStatus.Charging:
                        {
                            this.power.powerOutputInt = shieldPowerRequiredCharging;
                            break;
                        }
                    case enumShieldStatus.Sustaining:
                        {
                            this.power.powerOutputInt = shieldPowerRequiredSustaining;
                            break;
                        }
                }
            }
            else
            {
                //Log.Message("shieldField is null in tick event, creating new one.");
                shieldField = new ShieldField(this, base.Position, shieldMaxShieldStrength, shieldInitialShieldStrength, shieldShieldRadius, shieldRechargeTickDelay, shieldRecoverWarmup, shieldBlockIndirect, shieldBlockDirect, shieldFireSupression, shieldInterceptDropPod, shieldStructuralIntegrityMode, colourRed, colourGreen, colourBlue);
            }
        }
Exemplo n.º 2
0
        //On spawn, get the power component reference
        public override void SpawnSetup()
        {
            //Setup UI
            UI_DIRECT_OFF = ContentFinder<Texture2D>.Get("UI/DirectOff", true);
            UI_DIRECT_ON = ContentFinder<Texture2D>.Get("UI/DirectOn", true);
            UI_INDIRECT_OFF = ContentFinder<Texture2D>.Get("UI/IndirectOff", true);
            UI_INDIRECT_ON = ContentFinder<Texture2D>.Get("UI/IndirectOn", true);
            UI_FIRE_OFF = ContentFinder<Texture2D>.Get("UI/FireOff", true);
            UI_FIRE_ON = ContentFinder<Texture2D>.Get("UI/FireOn", true);
            UI_INTERCEPT_DROPPOD_OFF = ContentFinder<Texture2D>.Get("UI/FireOff", true);
            UI_INTERCEPT_DROPPOD_ON = ContentFinder<Texture2D>.Get("UI/FireOn", true);

            UI_REPAIR_ON = ContentFinder<Texture2D>.Get("UI/RepairON", true);
            UI_REPAIR_OFF = ContentFinder<Texture2D>.Get("UI/RepairOFF", true);

            UI_SHOW_ON = ContentFinder<Texture2D>.Get("UI/ShieldShowOn", true);
            UI_SHOW_OFF = ContentFinder<Texture2D>.Get("UI/ShieldShowOff", true);

            base.SpawnSetup();
            this.power = base.GetComp<CompPowerTrader>();
            if (def is ShieldBuildingThingDef)
            {
                //Read in variables from the custom MyThingDef
                shieldMaxShieldStrength = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldMaxShieldStrength;
                shieldInitialShieldStrength = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldInitialShieldStrength;
                shieldShieldRadius = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldShieldRadius;

                shieldPowerRequiredCharging = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldPowerRequiredCharging;
                shieldPowerRequiredSustaining = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldPowerRequiredSustaining;

                shieldRechargeTickDelay = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldRechargeTickDelay;
                shieldRecoverWarmup = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldRecoverWarmup;

                shieldBlockIndirect = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldBlockIndirect;
                shieldBlockDirect = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldBlockDirect;
                shieldFireSupression = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldFireSupression;
                shieldInterceptDropPod = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldInterceptDropPod;

                shieldStructuralIntegrityMode = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).shieldStructuralIntegrityMode;

                colourRed = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).colourRed;
                colourGreen = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).colourGreen;
                colourBlue = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).colourBlue;

                SIFBuildings = ((Enhanced_Development.Shields.ShieldBuildingThingDef)def).SIFBuildings;
                //Log.Error("Count:" + SIFBuildings.Count);
            }
            else
            {
                Log.Error("Shield definition not of type \"ShieldBuildingThingDef\"");
            }

            if (shieldField == null)
            {
                shieldField = new ShieldField(this, base.Position, shieldMaxShieldStrength, shieldInitialShieldStrength, shieldShieldRadius, shieldRechargeTickDelay, shieldRecoverWarmup, shieldBlockIndirect, shieldBlockDirect, shieldFireSupression, shieldInterceptDropPod, shieldStructuralIntegrityMode, colourRed, colourGreen, colourBlue);
            }

            //shieldField.setupValidBuildings();
        }