Esempio n. 1
0
 public override void TickRare()
 {
     if (this.power.PowerOn)
     {
         IntVec3 loc1  = this.Position + IntVec3Utility.RotatedBy(IntVec3.South, this.Rotation);
         IntVec3 loc2  = this.Position + IntVec3Utility.RotatedBy(IntVec3.North, this.Rotation);
         Room    room1 = GridsUtility.GetRoom(loc1);
         if (room1 == null)
         {
             return;
         }
         Room room2 = GridsUtility.GetRoom(loc2);
         if (room2 == null || room1 == room2 || room1.UsesOutdoorTemperature && room2.UsesOutdoorTemperature)
         {
             return;
         }
         float targetTemp = !room1.UsesOutdoorTemperature ? (!room2.UsesOutdoorTemperature ? (float)((double)room1.Temperature * (double)room1.CellCount + (double)room2.Temperature * (double)room2.CellCount) / (float)(room1.CellCount + room2.CellCount) : room2.Temperature) : room1.Temperature;
         if (!room1.UsesOutdoorTemperature)
         {
             this.Equalize(room1, targetTemp);
         }
         if (room2.UsesOutdoorTemperature)
         {
             return;
         }
         this.Equalize(room2, targetTemp);
     }
 }
Esempio n. 2
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            Building_CPRdummy.Ui_Change = ContentFinder <Texture2D> .Get("UI/UI_Change Button", true);

            if (this.MyCustomJob == null)
            {
                this.MyCustomJob = new Job(DefDatabase <JobDef> .GetNamed("GoToAndWaitForeverCPR", true), (LocalTargetInfo)((Thing)this), (LocalTargetInfo)InteractionCell);
            }
            this.ShotShield = this.Position + IntVec3Utility.RotatedBy(new Vector3(0.0f, 0.0f, 3f).ToIntVec3(), this.Rotation);
        }
Esempio n. 3
0
        private Toil Toils_Training(TargetIndex targetIndex)
        {
            Toil toil = new Toil();

            toil.initAction = (Action)(() =>
            {
                toil.actor.pather.StopDead();
                Building_Trainable X = (Building_Trainable)this.TargetA;

                switch (X.def.defName)
                {
                case "ShootingRange":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    IntVec3 shooter = TargetA.Cell + IntVec3Utility.RotatedBy(new Vector3(0.0f, 0.0f, 3f).ToIntVec3(), X.Rotation);
                    Projectile projectile = (Projectile)ThingMaker.MakeThing(ThingDef.Named("TrainingBullet"), (ThingDef)null);
                    GenSpawn.Spawn((Thing)projectile, pawn.Position, Map);
                    projectile.Launch((Thing)pawn, pawn.DrawPos, shooter, (Thing)null);

                    SoundDef Sound_shoot = SoundDef.Named("ShotRevolver");
                    Sound_shoot.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None));
                    break;

                case "CPRdummy":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    MoteMaker.ThrowMetaIcon(this.TargetA.Cell, this.Map, ThingDef.Named("Mote_HealingCross"));
                    break;

                case "Holodeck":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    IntVec3 bubble_pos = new IntVec3(TargetA.Cell.x + 1, TargetA.Cell.y, TargetA.Cell.z);

                    MoteMaker.MakeStaticMote(bubble_pos, Map, DefDatabase <ThingDef> .GetNamed("Mote_Speech"), 1f);
                    break;

                case "PunchingBag":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    MoteMaker.ThrowDustPuff(TargetA.Cell, Map, 1.0f);

                    SoundDef Sound_PBAG = SoundDef.Named("Pawn_Melee_Punch_HitPawn");
                    Sound_PBAG.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None));
                    break;

                default: return;
                }
            });
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
Esempio n. 4
0
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            var map = Find.CurrentMap;

            if (map == null)
            {
                return;
            }
            var targetCell = center + IntVec3Utility.RotatedBy(IntVec3.North, rot);
            var sourceCell = center + IntVec3Utility.RotatedBy(IntVec3.South, rot);

            if (!targetCell.InBounds(map) || !sourceCell.InBounds(map))
            {
                return;
            }
            DrawArrow(sourceCell, rot, sourceCell.Impassable(map) ? BlockedArrowColor : DefaultArrowColor);
            DrawArrow(targetCell, rot, targetCell.Impassable(map) ? BlockedArrowColor : DefaultArrowColor);
        }
Esempio n. 5
0
        public override void TickRare()
        {
            if (!compPowerTrader.PowerOn)
            {
                return;
            }

            IntVec3 intVec3_1 = Position + IntVec3Utility.RotatedBy(IntVec3.South, Rotation);
            IntVec3 intVec3_2 = Position + IntVec3Utility.RotatedBy(IntVec3.North, Rotation);
            bool    flag      = false;

            if (!GenGrid.Impassable(intVec3_2, Map) && !GenGrid.Impassable(intVec3_1, Map))
            {
                float temperature1 = GridsUtility.GetTemperature(intVec3_2, Map);
                float temperature2 = GridsUtility.GetTemperature(intVec3_1, Map);


                //Check for Mode
                bool _cooling = true;
                if (m_Mode == EnumCoolerMode.Cooling)
                {
                    _cooling = true;
                }
                else if (m_Mode == EnumCoolerMode.Heating)
                {
                    _cooling = false;
                }
                else if (m_Mode == EnumCoolerMode.Auto)
                {
                    if (temperature1 > compTempControl.targetTemperature)
                    {
                        //Log.Message("Auto Cooling");
                        _cooling = true;
                    }
                    else
                    {
                        //Log.Message("Auto Heating");
                        _cooling = false;
                    }
                }

                float a;
                float energyLimit;
                float _TemperatureDifferance;
                float num2;

                if (_cooling)
                {
                    //Log.Message("Cooling");
                    _TemperatureDifferance = temperature1 - temperature2;
                    if (temperature1 - TemperatureDiffThreshold > _TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 - TemperatureDiffThreshold;
                    }
                    num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference;
                    if (num2 < 0.0f)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)(compTempControl.Props.energyPerSecond * (double)num2 * UnknownConst_2);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }
                else
                {
                    //Log.Message("Heating");
                    _TemperatureDifferance = temperature1 - temperature2;
                    if (temperature1 + TemperatureDiffThreshold > _TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 + TemperatureDiffThreshold;
                    }
                    num2 = 1.0f - _TemperatureDifferance * EfficiencyLossPerDegreeDifference;
                    if (num2 < 0.0f)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)(compTempControl.Props.energyPerSecond * -(double)num2 * UnknownConst_2);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, Map, energyLimit, compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }

                if (flag)
                {
                    GridsUtility.GetRoomGroup(intVec3_2, Map).Temperature -= a;
                    GenTemperature.PushHeat(intVec3_1, Map, (float)(+(double)energyLimit * HeatOutputMultiplier));
                }
            }


            CompProperties_Power props = compPowerTrader.Props;

            if (flag)
            {
                compPowerTrader.PowerOutput = -props.basePowerConsumption;
            }
            else
            {
                compPowerTrader.PowerOutput = -props.basePowerConsumption * compTempControl.Props.lowPowerConsumptionFactor;
            }

            compTempControl.operatingAtHighPower = flag;
        }
        public override void TickRare()
        {
            if (!this.compPowerTrader.PowerOn)
            {
                return;
            }

            IntVec3 intVec3_1 = this.Position + IntVec3Utility.RotatedBy(IntVec3.South, this.Rotation);
            IntVec3 intVec3_2 = this.Position + IntVec3Utility.RotatedBy(IntVec3.North, this.Rotation);
            bool    flag      = false;

            if (!GenGrid.Impassable(intVec3_2, this.Map) && !GenGrid.Impassable(intVec3_1, this.Map))
            {
                float temperature1 = GridsUtility.GetTemperature(intVec3_2, this.Map);
                float temperature2 = GridsUtility.GetTemperature(intVec3_1, this.Map);


                //Check for Mode
                bool _cooling = true;
                if (this.m_Mode == enumCoolerMode.Cooling)
                {
                    _cooling = true;
                }
                else if (this.m_Mode == enumCoolerMode.Heating)
                {
                    _cooling = false;
                }
                else if (this.m_Mode == enumCoolerMode.Auto)
                {
                    //Log.Message("T1: " + temperature1 + "T2: " + temperature2 + "TT: " + this.compTempControl.targetTemperature);
                    if (temperature1 > this.compTempControl.targetTemperature)
                    {
                        //Log.Message("Auto Cooling");
                        _cooling = true;
                    }
                    else
                    {
                        //Log.Message("Auto Heating");
                        _cooling = false;
                    }
                }

                float a           = 0.0f;
                float energyLimit = 0.0f;

                if (_cooling)
                {
                    //Log.Message("Cooling");
                    float _TemperatureDifferance = temperature1 - temperature2;
                    if ((double)temperature1 - 40.0 > (double)_TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 - 40f;
                    }
                    float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0));
                    if ((double)num2 < 0.0)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * (double)num2 * 4.16666650772095);
                    a           = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature);
                    flag        = !Mathf.Approximately(a, 0.0f);
                }
                else
                {
                    //Log.Message("Heating");
                    float _TemperatureDifferance = temperature1 - temperature2;
                    if ((double)temperature1 + 40.0 > (double)_TemperatureDifferance)
                    {
                        _TemperatureDifferance = temperature1 + 40f;
                    }
                    float num2 = (float)(1.0 - (double)_TemperatureDifferance * (1.0 / 130.0));
                    if ((double)num2 < 0.0)
                    {
                        num2 = 0.0f;
                    }
                    energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * -(double)num2 * 4.16666650772095);
                    //energyLimit = (float)((double)this.compTempControl.Props.energyPerSecond * 4.16666650772095 * -1);
                    a    = GenTemperature.ControlTemperatureTempChange(intVec3_1, this.Map, energyLimit, this.compTempControl.targetTemperature);
                    flag = !Mathf.Approximately(a, 0.0f);
                    //Log.Message("TempDiff: " + _TemperatureDifferance + " num2: " + num2 + " EnergyLimit: " + energyLimit + " a: " + a);
                }

                if (flag)
                {
                    GridsUtility.GetRoomGroup(intVec3_2, this.Map).Temperature -= a;
                    GenTemperature.PushHeat(intVec3_1, this.Map, (float)(+(double)energyLimit * 1.25));
                }
            }


            CompProperties_Power props = this.compPowerTrader.Props;

            if (flag)
            {
                this.compPowerTrader.PowerOutput = -props.basePowerConsumption;
            }
            else
            {
                this.compPowerTrader.PowerOutput = -props.basePowerConsumption * this.compTempControl.Props.lowPowerConsumptionFactor;
            }
            this.compTempControl.operatingAtHighPower = flag;
        }