예제 #1
0
    public void SunUpdate()
    {
        int currentEnergy = this.currentEnergy;
        int num1;

        if (TOD_Sky.get_Instance().get_IsNight())
        {
            num1 = 0;
        }
        else
        {
            Vector3 vector3    = Vector3.op_Subtraction(((GameObject)TOD_Sky.get_Instance().get_Components().Sun).get_transform().get_position(), ((Component)this.sunSampler).get_transform().get_position());
            Vector3 normalized = ((Vector3) ref vector3).get_normalized();
            float   num2       = Mathf.InverseLerp(this.dot_minimum, this.dot_maximum, Vector3.Dot(((Component)this.sunSampler).get_transform().get_forward(), normalized));
            if ((double)num2 > 0.0 && !this.IsVisible(Vector3.op_Addition(((Component)this.sunSampler).get_transform().get_position(), Vector3.op_Multiply(normalized, 100f)), 101f))
            {
                num2 = 0.0f;
            }
            num1 = Mathf.FloorToInt((float)this.maximalPowerOutput * num2 * this.healthFraction);
        }
        int num3 = this.currentEnergy != num1 ? 1 : 0;

        this.currentEnergy = num1;
        if (num3 == 0)
        {
            return;
        }
        this.MarkDirty();
    }
 public static bool TrySwitchToolTo(
     NPCHumanContext c,
     NPCPlayerApex.ToolTypeEnum toolDay,
     NPCPlayerApex.ToolTypeEnum toolNight)
 {
     if (c != null)
     {
         Item obj            = (Item)null;
         uint svActiveItemId = c.Human.svActiveItemID;
         if (Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null))
         {
             obj = !TOD_Sky.get_Instance().get_IsDay() ? SwitchToolOperator.FindTool(c, toolNight) : SwitchToolOperator.FindTool(c, toolDay);
         }
         if (obj != null)
         {
             c.Human.UpdateActiveItem(obj.uid);
             if ((int)svActiveItemId != (int)c.Human.svActiveItemID)
             {
                 c.Human.NextToolSwitchTime = Time.get_realtimeSinceStartup() + c.Human.ToolSwitchFrequency;
                 c.SetFact(NPCPlayerApex.Facts.CurrentWeaponType, (byte)0, true, true);
                 c.SetFact(NPCPlayerApex.Facts.CurrentToolType, (byte)c.Human.GetCurrentToolTypeEnum(), true, true);
             }
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
 private void Start()
 {
     if (!Object.op_Implicit((Object)TOD_Sky.get_Instance()))
     {
         return;
     }
     ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour = (__Null)(double)PlayerPrefs.GetFloat("DevTime");
 }
예제 #4
0
 private void Update()
 {
     if (Object.op_Equality((Object)TOD_Sky.get_Instance(), (Object)null))
     {
         return;
     }
     this.slider.set_value((float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour);
 }
예제 #5
0
 public override void Load(BaseNetworkable.LoadInfo info)
 {
     base.Load(info);
     if (info.msg.environment == null || !Object.op_Implicit((Object)TOD_Sky.get_Instance()))
     {
         return;
     }
     ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).set_DateTime(DateTime.FromBinary((long)((Environment)info.msg.environment).dateTime));
 }
예제 #6
0
 public bool CanPlayInEnvironment(
     int currentBiome,
     int currentTopology,
     float currentRain,
     float currentSnow,
     float currentWind)
 {
     return((!Object.op_Implicit((Object)TOD_Sky.get_Instance()) || (double)this.time.Evaluate((float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour) >= 0.0) && (this.biomes == -1 || (this.biomes & currentBiome) != null) && (this.topologies == -1 || (this.topologies & currentTopology) == null) && (((double)this.rain.min <= 0.0 && (double)this.rain.max >= 1.0 || (double)currentRain >= (double)this.rain.min) && (double)currentRain <= (double)this.rain.max) && (((double)this.snow.min <= 0.0 && (double)this.snow.max >= 1.0 || (double)currentSnow >= (double)this.snow.min) && (double)currentSnow <= (double)this.snow.max && (((double)this.wind.min <= 0.0 && (double)this.wind.max >= 1.0 || (double)currentWind >= (double)this.wind.min) && (double)currentWind <= (double)this.wind.max)));
 }
예제 #7
0
 public void OnValue(float f)
 {
     if (Object.op_Equality((Object)TOD_Sky.get_Instance(), (Object)null))
     {
         return;
     }
     ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour = (__Null)(double)f;
     TOD_Sky.get_Instance().UpdateAmbient();
     TOD_Sky.get_Instance().UpdateReflection();
     TOD_Sky.get_Instance().UpdateFog();
 }
예제 #8
0
        public static void addtime(ConsoleSystem.Arg arg)
        {
            if (Object.op_Equality((Object)TOD_Sky.get_Instance(), (Object)null))
            {
                return;
            }
            DateTime dateTime = ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).get_DateTime();

            dateTime = dateTime.Add(arg.GetTimeSpan(0));
            ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).set_DateTime(dateTime);
        }
예제 #9
0
 private void CountHours()
 {
     if (!Object.op_Implicit((Object)TOD_Sky.get_Instance()))
     {
         return;
     }
     if (this.lastRun != 0L)
     {
         this.hoursRemaining -= (float)(((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).get_DateTime().Subtract(DateTime.FromBinary(this.lastRun)).TotalSeconds / 60.0 / 60.0);
     }
     this.lastRun = ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).get_DateTime().ToBinary();
 }
예제 #10
0
    public float CalculateSunExposure()
    {
        if (TOD_Sky.get_Instance().get_IsNight())
        {
            return(0.0f);
        }
        Vector3    vector3_1  = Vector3.op_Addition(((Component)this).get_transform().get_position(), new Vector3(0.0f, 1f, 0.0f));
        Vector3    vector3_2  = Vector3.op_Subtraction(((GameObject)TOD_Sky.get_Instance().get_Components().Sun).get_transform().get_position(), vector3_1);
        Vector3    normalized = ((Vector3) ref vector3_2).get_normalized();
        RaycastHit raycastHit;

        return(Physics.Raycast(vector3_1, normalized, ref raycastHit, 100f, 10551297) ? 0.0f : 1f);
    }
예제 #11
0
    private void OnGUI()
    {
        if (!Object.op_Implicit((Object)TOD_Sky.get_Instance()))
        {
            return;
        }
        float num1 = (float)Screen.get_width() * 0.2f;
        Rect  rect;

        ((Rect) ref rect).\u002Ector((float)Screen.get_width() - (num1 + 20f), (float)Screen.get_height() - 30f, num1, 20f);
        float    hour  = (float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour;
        float    num2  = GUI.HorizontalSlider(rect, hour, 0.0f, 24f);
        ref Rect local = ref rect;
 public override void VehicleFixedUpdate()
 {
     base.VehicleFixedUpdate();
     if (this.isClient)
     {
         return;
     }
     if ((double)Time.get_time() > (double)this.lastPlayerInputTime + 0.5)
     {
         this.SetDefaultInputState();
     }
     this.MovementUpdate();
     this.SetFlag(BaseEntity.Flags.Reserved6, TOD_Sky.get_Instance().get_IsNight(), false, true);
 }
예제 #13
0
 public void LightCheck()
 {
     if (TOD_Sky.get_Instance().get_IsNight() && !this.lightsOn)
     {
         this.SetLightsOn(true);
     }
     else
     {
         if (!this.lightsOn)
         {
             return;
         }
         this.SetLightsOn(false);
     }
 }
예제 #14
0
    protected void Update()
    {
        if (!Object.op_Implicit((Object)TerrainMeta.BiomeMap) || !Object.op_Implicit((Object)TOD_Sky.get_Instance()))
        {
            return;
        }
        TOD_Sky instance = TOD_Sky.get_Instance();
        long    num1     = 36000000000;
        long    num2     = (long)World.Seed + ((TOD_CycleParameters)instance.Cycle).get_Ticks();
        long    num3     = 18L * num1;
        long    num4     = 6L * num1;
        long    num5     = num2 / num3;
        float   t        = Mathf.InverseLerp(0.0f, (float)num4, (float)(num2 % num3));

        this.state = Climate.WeatherState.Fade(this.GetWeatherState((uint)((ulong)num5 % (ulong)uint.MaxValue)), this.GetWeatherState((uint)((ulong)(num5 + 1L) % (ulong)uint.MaxValue)), t);
        this.state.Override(this.Overrides);
    }
예제 #15
0
 public override void Save(BaseNetworkable.SaveInfo info)
 {
     base.Save(info);
     info.msg.environment = (__Null)Pool.Get <Environment>();
     if (Object.op_Implicit((Object)TOD_Sky.get_Instance()))
     {
         ((Environment)info.msg.environment).dateTime = (__Null)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).get_DateTime().ToBinary();
     }
     if (Object.op_Implicit((Object)SingletonComponent <Climate> .Instance))
     {
         ((Environment)info.msg.environment).clouds = (__Null)(double)((Climate)SingletonComponent <Climate> .Instance).Overrides.Clouds;
         ((Environment)info.msg.environment).fog    = (__Null)(double)((Climate)SingletonComponent <Climate> .Instance).Overrides.Fog;
         ((Environment)info.msg.environment).wind   = (__Null)(double)((Climate)SingletonComponent <Climate> .Instance).Overrides.Wind;
         ((Environment)info.msg.environment).rain   = (__Null)(double)((Climate)SingletonComponent <Climate> .Instance).Overrides.Rain;
     }
     ((Environment)info.msg.environment).engineTime = (__Null)(double)Time.get_realtimeSinceStartup();
 }
예제 #16
0
    public static float GetTemperature(Vector3 position)
    {
        if (!Object.op_Implicit((Object)SingletonComponent <Climate> .Instance) || !Object.op_Implicit((Object)TOD_Sky.get_Instance()))
        {
            return(15f);
        }
        Climate.ClimateParameters src;
        Climate.ClimateParameters dst;
        float blendParameters = ((Climate)SingletonComponent <Climate> .Instance).FindBlendParameters(position, out src, out dst);

        if (src == null || dst == null)
        {
            return(15f);
        }
        float hour = (float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour;

        return(Mathf.Lerp(src.Temperature.Evaluate(hour), dst.Temperature.Evaluate(hour), blendParameters));
    }
예제 #17
0
 public static Admin.ServerInfoOutput ServerInfo()
 {
     return(new Admin.ServerInfoOutput()
     {
         Hostname = Server.hostname,
         MaxPlayers = Server.maxplayers,
         Players = BasePlayer.activePlayerList.Count,
         Queued = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Queued,
         Joining = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).connectionQueue.Joining,
         EntityCount = BaseNetworkable.serverEntities.Count,
         GameTime = Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null) ? ((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).get_DateTime().ToString() : DateTime.UtcNow.ToString(),
         Uptime = (int)Time.get_realtimeSinceStartup(),
         Map = Server.level,
         Framerate = (float)Performance.report.frameRate,
         Memory = (int)Performance.report.memoryAllocations,
         Collections = (int)Performance.report.memoryCollections,
         NetworkIn = Net.sv == null ? 0 : (int)((NetworkPeer)Net.sv).GetStat((Connection)null, (NetworkPeer.StatTypeLong) 3),
         NetworkOut = Net.sv == null ? 0 : (int)((NetworkPeer)Net.sv).GetStat((Connection)null, (NetworkPeer.StatTypeLong) 1),
         Restarting = ((ServerMgr)SingletonComponent <ServerMgr> .Instance).Restarting,
         SaveCreatedTime = SaveRestore.SaveCreatedTime.ToString()
     });
 }
예제 #18
0
 public void RefreshLightExposure()
 {
     if (!Server.plantlightdetection)
     {
         this.lightExposure = this.plantProperty.timeOfDayHappiness.Evaluate((float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour);
     }
     else
     {
         this.lightExposure = this.CalculateSunExposure() * this.plantProperty.timeOfDayHappiness.Evaluate((float)((TOD_CycleParameters)TOD_Sky.get_Instance().Cycle).Hour);
         if ((double)this.lightExposure > 0.0)
         {
             return;
         }
         this.lightExposure = this.CalculateArtificialLightExposure() * 2f;
     }
 }
예제 #19
0
        private IEnumerator EquipTool(HTNPlayer target)
        {
            yield return((object)CoroutineEx.waitForSeconds(0.25f));

            if (!Object.op_Equality((Object)target, (Object)null) && !target.IsDestroyed && (!target.IsDead() && !target.IsWounded()) && (!Object.op_Equality((Object)target.inventory, (Object)null) && target.inventory.containerBelt != null))
            {
                int slot1 = 1;
                if (Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null) && TOD_Sky.get_Instance().get_IsNight())
                {
                    slot1 = 2;
                }
                Item slot = target.inventory.containerBelt.GetSlot(slot1);
                if (slot == null)
                {
                    slot = target.inventory.containerBelt.GetSlot(0);
                    if (slot == null)
                    {
                        yield break;
                    }
                }
                target.UpdateActiveItem(slot.uid);
                yield return((object)CoroutineEx.waitForSeconds(0.25f));

                ScientistJunkpileDomain aiDomain = target.AiDomain as ScientistJunkpileDomain;
                if (Object.op_Implicit((Object)aiDomain))
                {
                    if (slot.info.category == ItemCategory.Weapon)
                    {
                        BaseEntity heldEntity = slot.GetHeldEntity();
                        if (heldEntity is BaseProjectile)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true);
                            aiDomain.ReloadFirearm();
                        }
                        else if (heldEntity is BaseMelee)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true);
                        }
                        else if (heldEntity is ThrownWeapon)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true);
                        }
                    }
                    else if (slot.info.category == ItemCategory.Medical)
                    {
                        aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true);
                    }
                    else if (slot.info.category == ItemCategory.Tool)
                    {
                        HeldEntity heldEntity = target.GetHeldEntity();
                        if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.LightsOn())
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true);
                        }
                        else
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ResearchItem, true, true, true);
                        }
                    }
                }
            }
        }