Exemplo n.º 1
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("BowWeapon.OnRpcMessage"))
     {
         if (rpc == 4228048190u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - BowReload "));
             }
             using (TimeWarning.New("BowReload"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.IsActiveItem.Test(4228048190u, "BowReload", this, player))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         RPCMessage rPCMessage = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg2 = rPCMessage;
                         BowReload(msg2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in BowReload");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemplo n.º 2
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("ElevatorLift.OnRpcMessage"))
     {
         if (rpc == 4061236510u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - Server_RaiseLowerFloor "));
             }
             using (TimeWarning.New("Server_RaiseLowerFloor"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.IsVisible.Test(4061236510u, "Server_RaiseLowerFloor", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         RPCMessage rPCMessage = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg2 = rPCMessage;
                         Server_RaiseLowerFloor(msg2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in Server_RaiseLowerFloor");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemplo n.º 3
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("Cassette.OnRpcMessage"))
     {
         if (rpc == 4031457637u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - Server_MakeNewFile "));
             }
             using (TimeWarning.New("Server_MakeNewFile"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.CallsPerSecond.Test(4031457637u, "Server_MakeNewFile", this, player, 1uL))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         RPCMessage rPCMessage = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage msg2 = rPCMessage;
                         Server_MakeNewFile(msg2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in Server_MakeNewFile");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemplo n.º 4
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("Candle.OnRpcMessage"))
     {
         if (rpc == 2523893445u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (ConVar.Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - SetWantsOn "));
             }
             using (TimeWarning.New("SetWantsOn"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.IsVisible.Test(2523893445u, "SetWantsOn", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         RPCMessage rPCMessage = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage wantsOn = rPCMessage;
                         SetWantsOn(wantsOn);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in SetWantsOn");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemplo n.º 5
0
 public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
 {
     using (TimeWarning.New("BaseLock.OnRpcMessage"))
     {
         if (rpc == 3572556655u && player != null)
         {
             Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
             if (Global.developer > 2)
             {
                 Debug.Log(string.Concat("SV_RPCMessage: ", player, " - RPC_TakeLock "));
             }
             using (TimeWarning.New("RPC_TakeLock"))
             {
                 using (TimeWarning.New("Conditions"))
                 {
                     if (!RPC_Server.MaxDistance.Test(3572556655u, "RPC_TakeLock", this, player, 3f))
                     {
                         return(true);
                     }
                 }
                 try
                 {
                     using (TimeWarning.New("Call"))
                     {
                         RPCMessage rPCMessage = default(RPCMessage);
                         rPCMessage.connection = msg.connection;
                         rPCMessage.player     = player;
                         rPCMessage.read       = msg.read;
                         RPCMessage rpc2 = rPCMessage;
                         RPC_TakeLock(rpc2);
                     }
                 }
                 catch (Exception exception)
                 {
                     Debug.LogException(exception);
                     player.Kick("RPC Error in RPC_TakeLock");
                 }
             }
             return(true);
         }
     }
     return(base.OnRpcMessage(player, rpc, msg));
 }
Exemplo n.º 6
0
 internal void DoDamage(
     BaseEntity ent,
     TriggerHurtEx.HurtType type,
     List <DamageTypeEntry> damage,
     GameObjectRef effect,
     float multiply = 1f)
 {
     if (!this.damageEnabled)
     {
         return;
     }
     using (TimeWarning.New("TriggerHurtEx.DoDamage", 0.1f))
     {
         if (damage != null && damage.Count > 0)
         {
             BaseCombatEntity baseCombatEntity = ent as BaseCombatEntity;
             if (Object.op_Implicit((Object)baseCombatEntity))
             {
                 HitInfo info = new HitInfo();
                 info.damageTypes.Add(damage);
                 info.damageTypes.ScaleAll(multiply);
                 info.DoHitEffects = true;
                 info.DidHit       = true;
                 info.Initiator    = ((Component)this).get_gameObject().ToBaseEntity();
                 info.PointStart   = ((Component)this).get_transform().get_position();
                 info.PointEnd     = ((Component)baseCombatEntity).get_transform().get_position();
                 if (type == TriggerHurtEx.HurtType.Simple)
                 {
                     baseCombatEntity.Hurt(info);
                 }
                 else
                 {
                     baseCombatEntity.OnAttacked(info);
                 }
             }
         }
         if (!effect.isValid)
         {
             return;
         }
         Effect.server.Run(effect.resourcePath, ent, StringPool.closest, ((Component)this).get_transform().get_position(), Vector3.get_up(), (Connection)null, false);
     }
 }
Exemplo n.º 7
0
        public override void Cycle()
        {
            base.Cycle();
            if (!this.IsConnected())
            {
                return;
            }
            Stopwatch stopwatch = Pool.Get <Stopwatch>();

            stopwatch.Reset();
            stopwatch.Start();
            do
            {
Label0:
                if (!this.peer.Receive())
                {
                    break;
                }
                if (this.peer.incomingBytesUnread <= Facepunch.Network.Raknet.Server.MaxPacketSize)
                {
                    Connection connection = base.FindConnection(this.peer.incomingGUID);
                    if (connection != null)
                    {
                        using (TimeWarning timeWarning = TimeWarning.New("ConnectedPacket", (long)20))
                        {
                            this.ConnectedPacket(connection);
                        }
                    }
                    else
                    {
                        using (timeWarning = TimeWarning.New("UnconnectedPacket", (long)20))
                        {
                            this.UnconnectedPacket();
                        }
                    }
                }
                else
                {
                    goto Label0;
                }
            }while (stopwatch.Elapsed.TotalMilliseconds <= (double)Facepunch.Network.Raknet.Server.MaxReceiveTime);
            Pool.Free <Stopwatch>(ref stopwatch);
        }
Exemplo n.º 8
0
    public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
    {
        bool flag;

        using (TimeWarning timeWarning = TimeWarning.New("RHIB.OnRpcMessage", 0.1f))
        {
            if (rpc != 1382282393 || !(player != null))
            {
                return(base.OnRpcMessage(player, rpc, msg));
            }
            else
            {
                Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
                if (Global.developer > 2)
                {
                    Debug.Log(string.Concat("SV_RPCMessage: ", player, " - Server_Release "));
                }
                using (TimeWarning timeWarning1 = TimeWarning.New("Server_Release", 0.1f))
                {
                    try
                    {
                        using (TimeWarning timeWarning2 = TimeWarning.New("Call", 0.1f))
                        {
                            BaseEntity.RPCMessage rPCMessage = new BaseEntity.RPCMessage()
                            {
                                connection = msg.connection,
                                player     = player,
                                read       = msg.read
                            };
                            this.Server_Release(rPCMessage);
                        }
                    }
                    catch (Exception exception)
                    {
                        player.Kick("RPC Error in Server_Release");
                        Debug.LogException(exception);
                    }
                }
                flag = true;
            }
        }
        return(flag);
    }
Exemplo n.º 9
0
 public bool SwitchGroup(Group newGroup)
 {
     if (newGroup == this.@group)
     {
         return(false);
     }
     using (TimeWarning timeWarning = TimeWarning.New("SwitchGroup", 0.1f))
     {
         if (this.@group != null)
         {
             using (TimeWarning timeWarning1 = TimeWarning.New("group.Leave", 0.1f))
             {
                 [email protected](this);
             }
         }
         Group group = this.@group;
         this.@group = newGroup;
         if (this.@group != null)
         {
             using (timeWarning1 = TimeWarning.New("group.Join", 0.1f))
             {
                 [email protected](this);
             }
         }
         if (this.handler != null && this.@group != null)
         {
             using (timeWarning1 = TimeWarning.New("OnNetworkGroupChange", 0.1f))
             {
                 this.handler.OnNetworkGroupChange();
             }
         }
         using (timeWarning1 = TimeWarning.New("OnSubscriptionChange", 0.1f))
         {
             this.OnSubscriptionChange();
         }
         using (timeWarning1 = TimeWarning.New("OnGroupTransition", 0.1f))
         {
             this.OnGroupTransition(group);
         }
     }
     return(true);
 }
 public void SendNetworkUpdateImmediate(bool justCreated = false)
 {
     if (Rust.Application.isLoading)
     {
         return;
     }
     if (Rust.Application.isLoadingSave)
     {
         return;
     }
     if (this.IsDestroyed)
     {
         return;
     }
     if (this.net == null)
     {
         return;
     }
     if (!this.isSpawned)
     {
         return;
     }
     using (TimeWarning timeWarning = TimeWarning.New("SendNetworkUpdateImmediate", 0.1f))
     {
         base.LogEntry(BaseMonoBehaviour.LogEntryType.Network, 2, "SendNetworkUpdateImmediate");
         this.InvalidateNetworkCache();
         List <Connection> subscribers = this.GetSubscribers();
         if (subscribers != null && subscribers.Count > 0)
         {
             for (int i = 0; i < subscribers.Count; i++)
             {
                 Connection item       = subscribers[i];
                 BasePlayer basePlayer = item.player as BasePlayer;
                 if (!(basePlayer == null) && this.ShouldNetworkTo(basePlayer))
                 {
                     this.SendAsSnapshot(item, justCreated);
                 }
             }
         }
     }
     base.gameObject.SendOnSendNetworkUpdate(this as BaseEntity);
 }
 public void LoadIntoTexture(Texture2D tex)
 {
     if (!this.isValid)
     {
         return;
     }
     if (tex.width != this.width || tex.height != this.height || (int)tex.format != this.format)
     {
         return;
     }
     TimeWarning.BeginSample("Texture2D.LoadRawTextureData");
     tex.LoadRawTextureData(this.buffer, this.size);
     TimeWarning.EndSample();
     TimeWarning.BeginSample("Texture2D.Apply");
     tex.Apply(false);
     TimeWarning.EndSample();
     TimeWarning.BeginSample("Native.FreeTexture");
     AsyncTextureLoad.FreeTexture(ref this.buffer);
     TimeWarning.EndSample();
 }
Exemplo n.º 12
0
        public static void DisposeTimeWarning(TimeWarning timeWarning)
        {
            if (timeWarning == null)
            {
                return;
            }
            var instance     = _reverseLookup[timeWarning] as MetricsTimeWarning;
            var currentEpoch = GetCurrentEpoch();
            var duration     = currentEpoch - instance._startEpoch;

            if (duration >= instance._maxMilliseconds)
            {
                _stringBuilder.Clear();
                _stringBuilder.Append("TimeWarning: ");
                _stringBuilder.Append("["); _stringBuilder.Append(instance._name); _stringBuilder.Append("] ");
                _stringBuilder.Append(duration); _stringBuilder.Append("ms");
                Debug.LogWarning(_stringBuilder.ToString());
            }
            Pool.Free(ref instance);
        }
Exemplo n.º 13
0
 public void AddLifeStory(ulong playerID, PlayerLifeStory lifeStory)
 {
     if (UserPersistance.deaths == null || lifeStory == null)
     {
         return;
     }
     using (TimeWarning.New(nameof(AddLifeStory), 0.1f))
     {
         byte[] protoBytes;
         using (TimeWarning.New("ToProtoBytes", 0.1f))
             protoBytes = lifeStory.ToProtoBytes();
         UserPersistance.deaths.Execute("INSERT INTO data ( userid, born, died, info ) VALUES ( ?, ?, ?, ? )", new object[4]
         {
             (object)playerID.ToString(),
             (object)(int)lifeStory.timeBorn,
             (object)(int)lifeStory.timeDied,
             (object)protoBytes
         });
     }
 }
Exemplo n.º 14
0
 private void SetFlags()
 {
     using (TimeWarning.New("SetFlag"))
     {
         bool  b   = EngineOn() && !IsFlipped() && base.healthFraction > 0f && fuelSystem.HasFuel() && TimeSinceDriver() < 75f;
         Flags num = flags;
         SetFlag(Flags.Reserved3, steering > 0f, false, false);
         SetFlag(Flags.Reserved4, steering < 0f, false, false);
         SetFlag(Flags.Reserved1, b, false, false);
         SetFlag(Flags.Reserved2, EngineOn() && gasPedal != 0f, false, false);
         SetFlag(Flags.Reserved5, buoyancy.submergedFraction > 0.85f, false, false);
         SetFlag(Flags.Reserved6, fuelSystem.HasFuel(), false, false);
         SetFlag(Flags.Reserved7, GetLocalVelocity().sqrMagnitude < 0.5f && !HasAnyPassengers(), false, false);
         SetFlag(Flags.Reserved8, base.RecentlyPushed, false, false);
         if (num != flags)
         {
             Invoke(base.SendNetworkUpdate_Flags, 0f);
         }
     }
 }
Exemplo n.º 15
0
 public void Remove(uint crc, FileStorage.Type type, uint entityID)
 {
     using (TimeWarning.New("FileStorage.Remove", 0.1f))
     {
         if (this.db != null)
         {
             this.db.Execute("DELETE FROM data WHERE crc = ? AND filetype = ? AND entid = ?", new object[3]
             {
                 (object)(int)crc,
                 (object)(int)type,
                 (object)(int)entityID
             });
         }
         if (!this._cache.ContainsKey(crc))
         {
             return;
         }
         this._cache.Remove(crc);
     }
 }
Exemplo n.º 16
0
 public void AddLifeStory(ulong playerID, PlayerLifeStory lifeStory)
 {
     byte[] protoBytes;
     if (UserPersistance.deaths == null)
     {
         return;
     }
     if (lifeStory == null)
     {
         return;
     }
     using (TimeWarning timeWarning = TimeWarning.New("AddLifeStory", 0.1f))
     {
         using (TimeWarning timeWarning1 = TimeWarning.New("ToProtoBytes", 0.1f))
         {
             protoBytes = lifeStory.ToProtoBytes();
         }
         UserPersistance.deaths.Execute("INSERT INTO data ( userid, born, died, info ) VALUES ( ?, ?, ?, ? )", new object[] { playerID.ToString(), (int)lifeStory.timeBorn, (int)lifeStory.timeDied, protoBytes });
     }
 }
Exemplo n.º 17
0
        public OvenInfo GetOvenInfo(BaseOven oven)
        {
            using (TimeWarning.New("FurnaceSplitter.GetOvenInfo", 0.01f))
            {
                var result     = new OvenInfo();
                var smeltTimes = GetSmeltTimes(oven);

                if (smeltTimes.Count > 0)
                {
                    var   longestStack = smeltTimes.OrderByDescending(kv => kv.Value).First();
                    var   fuelUnits    = oven.fuelType.GetComponent <ItemModBurnable>().fuelAmount;
                    float neededFuel   = (float)Math.Ceiling(longestStack.Value * (BaseOven.cookingTemperature / 200.0f) / fuelUnits);

                    result.FuelNeeded = neededFuel;
                    result.ETA        = longestStack.Value;
                }

                return(result);
            }
        }
Exemplo n.º 18
0
 public static bool ShouldIgnore(BasePlayer ply)
 {
     using (TimeWarning.New("AntiHack.ShouldIgnore"))
     {
         if (ply.IsFlying)
         {
             ply.lastAdminCheatTime = UnityEngine.Time.realtimeSinceStartup;
         }
         else if ((ply.IsAdmin || ply.IsDeveloper) && ply.lastAdminCheatTime == 0f)
         {
             ply.lastAdminCheatTime = UnityEngine.Time.realtimeSinceStartup;
         }
         if (ply.IsAdmin)
         {
             if (ConVar.AntiHack.userlevel < 1)
             {
                 return(true);
             }
             if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat())
             {
                 return(true);
             }
         }
         if (ply.IsDeveloper)
         {
             if (ConVar.AntiHack.userlevel < 2)
             {
                 return(true);
             }
             if (ConVar.AntiHack.admincheat && ply.UsedAdminCheat())
             {
                 return(true);
             }
         }
         if (ply.IsSpectating())
         {
             return(true);
         }
         return(false);
     }
 }
 public void SendNetworkUpdate(BasePlayer.NetworkQueue queue = 0)
 {
     if (Rust.Application.isLoading)
     {
         return;
     }
     if (Rust.Application.isLoadingSave)
     {
         return;
     }
     if (this.IsDestroyed)
     {
         return;
     }
     if (this.net == null)
     {
         return;
     }
     if (!this.isSpawned)
     {
         return;
     }
     using (TimeWarning timeWarning = TimeWarning.New("SendNetworkUpdate", 0.1f))
     {
         base.LogEntry(BaseMonoBehaviour.LogEntryType.Network, 2, "SendNetworkUpdate");
         this.InvalidateNetworkCache();
         List <Connection> subscribers = this.GetSubscribers();
         if (subscribers != null && subscribers.Count > 0)
         {
             for (int i = 0; i < subscribers.Count; i++)
             {
                 BasePlayer item = subscribers[i].player as BasePlayer;
                 if (!(item == null) && this.ShouldNetworkTo(item))
                 {
                     item.QueueUpdate(queue, this);
                 }
             }
         }
     }
     base.gameObject.SendOnSendNetworkUpdate(this as BaseEntity);
 }
 private void DoEntityDestroy()
 {
     if (this.IsDestroyed)
     {
         return;
     }
     this.IsDestroyed = true;
     if (Rust.Application.isQuitting)
     {
         return;
     }
     this.DestroyShared();
     if (this.isServer)
     {
         this.DoServerDestroy();
     }
     using (TimeWarning timeWarning = TimeWarning.New("Registry.Entity.Unregister", 0.1f))
     {
         Rust.Registry.Entity.Unregister(base.gameObject);
     }
 }
Exemplo n.º 21
0
 public virtual void DoAttackShared(HitInfo info)
 {
     if (Interface.CallHook("OnPlayerAttack", this.GetOwnerPlayer(), info) != null)
     {
         return;
     }
     this.GetAttackStats(info);
     if (info.HitEntity != null)
     {
         using (TimeWarning timeWarning = TimeWarning.New("OnAttacked", (long)50))
         {
             info.HitEntity.OnAttacked(info);
         }
     }
     if (info.DoHitEffects)
     {
         if (!base.isServer)
         {
             using (timeWarning = TimeWarning.New("ImpactEffect", (long)20))
             {
                 Effect.client.ImpactEffect(info);
             }
         }
         else
         {
             using (timeWarning = TimeWarning.New("ImpactEffect", (long)20))
             {
                 Effect.server.ImpactEffect(info);
             }
         }
     }
     if (base.isServer && !base.IsDestroyed)
     {
         using (timeWarning = TimeWarning.New("UpdateItemCondition", (long)50))
         {
             this.UpdateItemCondition(info);
         }
         base.StartAttackCooldown(this.repeatDelay);
     }
 }
Exemplo n.º 22
0
 public void OnTriggerEnter(Collider collider)
 {
     if (this == null)
     {
         return;
     }
     using (TimeWarning timeWarning = TimeWarning.New("TriggerBase.OnTriggerEnter", 0.1f))
     {
         GameObject gameObject = this.InterestedInObject(collider.gameObject);
         if (gameObject != null)
         {
             if (this.contents == null)
             {
                 this.contents = new HashSet <GameObject>();
             }
             if (!this.contents.Contains(gameObject))
             {
                 int count = this.contents.Count;
                 this.contents.Add(gameObject);
                 this.OnObjectAdded(gameObject);
                 if (count == 0 && this.contents.Count == 1)
                 {
                     this.OnObjects();
                 }
             }
             else
             {
                 return;
             }
         }
         else
         {
             return;
         }
     }
     if (Debugging.checktriggers)
     {
         this.RemoveInvalidEntities();
     }
 }
Exemplo n.º 23
0
 /// <summary>
 /// Loot the given container
 /// </summary>
 /// <param name="player"></param>
 /// <param name="container"></param>
 /// <returns></returns>
 private bool LootContainer(BasePlayer player, StorageContainer container)
 {
     if (container.IsLocked())
     {
         player.ChatMessage(Lang("CantLoot", player.UserIDString));
         return(false);
     }
     if (!container.CanOpenLootPanel(player, container.panelName))
     {
         return(false);
     }
     container.SetFlag(BaseEntity.Flags.Open, true, false);
     using (TimeWarning.New("PlayerOpenLoot", 0.1f))
     {
         player.inventory.loot.StartLootingEntity(container, false);
         player.inventory.loot.AddContainer(container.inventory);
         player.inventory.loot.SendImmediate();
         player.ClientRPCPlayer(null, player, "RPC_OpenLootPanel", container.panelName);
         container.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
     }
     return(true);
 }
Exemplo n.º 24
0
    public uint Store(byte[] data, FileStorage.Type type, uint entityID, uint numID = 0)
    {
        uint num;

        using (TimeWarning timeWarning = TimeWarning.New("FileStorage.Store", 0.1f))
        {
            uint cRC = this.GetCRC(data, type);
            if (this.db != null)
            {
                this.db.Execute("INSERT OR REPLACE INTO data ( crc, data, entid, filetype, part ) VALUES ( ?, ?, ?, ?, ? )", new object[] { (int)cRC, data, (int)entityID, (int)type, (int)numID });
            }
            this._cache.Remove(cRC);
            this._cache.Add(cRC, new FileStorage.CacheData()
            {
                data     = data,
                entityID = entityID,
                numID    = numID
            });
            num = cRC;
        }
        return(num);
    }
Exemplo n.º 25
0
 public void Retire(GameObject instance)
 {
     if (!instance)
     {
         return;
     }
     using (TimeWarning.New("GameManager.Retire"))
     {
         if (BaseEntityEx.IsValid(instance.GetComponent <BaseEntity>()))
         {
             Debug.LogError("Trying to retire an entity without killing it first: " + instance.name);
         }
         if (!Rust.Application.isQuitting && ConVar.Pool.enabled && PoolableEx.SupportsPooling(instance))
         {
             pool.Push(instance);
         }
         else
         {
             Object.Destroy(instance);
         }
     }
 }
Exemplo n.º 26
0
 public void Retire(GameObject instance)
 {
     if (!instance)
     {
         return;
     }
     using (TimeWarning timeWarning = TimeWarning.New("GameManager.Retire", 0.1f))
     {
         if (instance.GetComponent <BaseEntity>().IsValid())
         {
             Debug.LogError(string.Concat("Trying to retire an entity without killing it first: ", instance.name));
         }
         if (Rust.Application.isQuitting || !ConVar.Pool.enabled || !instance.SupportsPooling())
         {
             UnityEngine.Object.Destroy(instance);
         }
         else
         {
             this.pool.Push(instance);
         }
     }
 }
Exemplo n.º 27
0
 public static WaterLevel.WaterInfo GetWaterInfo(Vector3 pos)
 {
     WaterLevel.WaterInfo waterInfo;
     using (TimeWarning timeWarning = TimeWarning.New("WaterLevel.GetWaterInfo", 0.1f))
     {
         WaterLevel.WaterInfo waterInfo1 = new WaterLevel.WaterInfo();
         float single = (TerrainMeta.WaterMap ? TerrainMeta.WaterMap.GetHeight(pos) : 0f);
         if (pos.y <= single)
         {
             float single1 = (TerrainMeta.HeightMap ? TerrainMeta.HeightMap.GetHeight(pos) : 0f);
             if (pos.y < single1 - 1f)
             {
                 single = 0f;
                 if (pos.y > single)
                 {
                     waterInfo = waterInfo1;
                     return(waterInfo);
                 }
             }
             if (!WaterSystem.Collision || !WaterSystem.Collision.GetIgnore(pos, 0.01f))
             {
                 waterInfo1.isValid      = true;
                 waterInfo1.currentDepth = Mathf.Max(0f, single - pos.y);
                 waterInfo1.overallDepth = Mathf.Max(0f, single - single1);
                 waterInfo1.surfaceLevel = single;
                 waterInfo = waterInfo1;
             }
             else
             {
                 waterInfo = waterInfo1;
             }
         }
         else
         {
             waterInfo = waterInfo1;
         }
     }
     return(waterInfo);
 }
Exemplo n.º 28
0
 public bool Trace(Ray ray, out RaycastHit hit, float forgivness = 0f, float maxDistance = float.PositiveInfinity)
 {
     using (TimeWarning.New("Hitbox.Trace"))
     {
         ray.origin    = InverseTransformPoint(ray.origin);
         ray.direction = InverseTransformDirection(ray.direction);
         if (type == HitboxDefinition.Type.BOX)
         {
             if (!new AABB(Vector3.zero, Size).Trace(ray, out hit, forgivness, maxDistance))
             {
                 return(false);
             }
         }
         else if (!new Capsule(Vector3.zero, Size.x, Size.y * 0.5f).Trace(ray, out hit, forgivness, maxDistance))
         {
             return(false);
         }
         hit.point  = TransformPoint(hit.point);
         hit.normal = TransformDirection(hit.normal);
         return(true);
     }
 }
Exemplo n.º 29
0
 public override BaseCorpse OnCreateCorpse(HTNAnimal target)
 {
     if (this.DeathEffect.isValid)
     {
         Effect.server.Run(this.DeathEffect.resourcePath, (BaseEntity)target, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
     }
     using (TimeWarning.New("Create corpse", 0.1f))
     {
         BaseCorpse baseCorpse = target.DropCorpse(this.CorpsePrefab.resourcePath);
         if (Object.op_Implicit((Object)baseCorpse))
         {
             if (Object.op_Inequality((Object)target.AiDomain, (Object)null) && Object.op_Inequality((Object)target.AiDomain.NavAgent, (Object)null) && target.AiDomain.NavAgent.get_isOnNavMesh())
             {
                 ((Component)baseCorpse).get_transform().set_position(Vector3.op_Addition(((Component)baseCorpse).get_transform().get_position(), Vector3.op_Multiply(Vector3.get_down(), target.AiDomain.NavAgent.get_baseOffset())));
             }
             baseCorpse.InitCorpse((BaseEntity)target);
             baseCorpse.Spawn();
             baseCorpse.TakeChildren((BaseEntity)target);
         }
         return(baseCorpse);
     }
 }
Exemplo n.º 30
0
 public static WaterLevel.WaterInfo GetBuoyancyWaterInfo(Vector3 pos, Vector2 posUV, float terrainHeight, float waterHeight)
 {
     WaterLevel.WaterInfo waterInfo;
     using (TimeWarning timeWarning = TimeWarning.New("WaterLevel.GetWaterInfo", 0.1f))
     {
         WaterLevel.WaterInfo waterInfo1 = new WaterLevel.WaterInfo();
         if (pos.y <= waterHeight)
         {
             bool flag = pos.y < terrainHeight - 1f;
             if (flag)
             {
                 waterHeight = 0f;
                 if (pos.y > waterHeight)
                 {
                     waterInfo = waterInfo1;
                     return(waterInfo);
                 }
             }
             int num = (TerrainMeta.TopologyMap ? TerrainMeta.TopologyMap.GetTopologyFast(posUV) : 0);
             if ((flag || (num & 246144) == 0) && WaterSystem.Collision && WaterSystem.Collision.GetIgnore(pos, 0.01f))
             {
                 waterInfo = waterInfo1;
             }
             else
             {
                 waterInfo1.isValid      = true;
                 waterInfo1.currentDepth = Mathf.Max(0f, waterHeight - pos.y);
                 waterInfo1.overallDepth = Mathf.Max(0f, waterHeight - terrainHeight);
                 waterInfo1.surfaceLevel = waterHeight;
                 waterInfo = waterInfo1;
             }
         }
         else
         {
             waterInfo = waterInfo1;
         }
     }
     return(waterInfo);
 }