예제 #1
0
 public void SetHeldEntity(BaseEntity ent)
 {
     if (!BaseEntityEx.IsValid(ent))
     {
         this.heldEntity.Set(null);
         MarkDirty();
     }
     else
     {
         if (this.heldEntity.uid == ent.net.ID)
         {
             return;
         }
         this.heldEntity.Set(ent);
         MarkDirty();
         if (BaseEntityEx.IsValid(ent))
         {
             HeldEntity heldEntity = ent as HeldEntity;
             if (heldEntity != null)
             {
                 heldEntity.SetupHeldEntity(this);
             }
         }
     }
 }
예제 #2
0
 private void OnTick()
 {
     if (attackEffect.isValid)
     {
         Effect.server.Run(attackEffect.resourcePath, base.transform.position, Vector3.up);
     }
     if (entityContents == null)
     {
         return;
     }
     BaseEntity[] array = entityContents.ToArray();
     foreach (BaseEntity baseEntity in array)
     {
         if (BaseEntityEx.IsValid(baseEntity))
         {
             BaseCombatEntity baseCombatEntity = baseEntity as BaseCombatEntity;
             if (!(baseCombatEntity == null))
             {
                 HitInfo hitInfo = new HitInfo();
                 hitInfo.damageTypes.Add(damageType);
                 hitInfo.DoHitEffects = true;
                 hitInfo.DidHit       = true;
                 hitInfo.PointStart   = base.transform.position;
                 hitInfo.PointEnd     = baseCombatEntity.transform.position;
                 baseCombatEntity.Hurt(hitInfo);
             }
         }
     }
 }
예제 #3
0
    public void DoRemove()
    {
        this.OnDirty = null;
        this.onCycle = null;
        if (isServer && uid != 0 && Network.Net.sv != null)
        {
            Network.Net.sv.ReturnUID(uid);
            uid = 0u;
        }
        if (contents != null)
        {
            contents.Kill();
            contents = null;
        }
        if (isServer)
        {
            RemoveFromWorld();
            RemoveFromContainer();
        }
        BaseEntity baseEntity = GetHeldEntity();

        if (BaseEntityEx.IsValid(baseEntity))
        {
            Debug.LogWarning("Item's Held Entity not removed!" + info.displayName.english + " -> " + baseEntity, baseEntity);
        }
    }
예제 #4
0
    public BaseEntity CreateConstruction(Target target, bool bNeedsValidPlacement = false)
    {
        GameObject gameObject = GameManager.server.CreatePrefab(fullName, Vector3.zero, Quaternion.identity, false);
        bool       flag       = UpdatePlacement(gameObject.transform, this, ref target);
        BaseEntity baseEntity = GameObjectEx.ToBaseEntity(gameObject);

        if (bNeedsValidPlacement && !flag)
        {
            if (BaseEntityEx.IsValid(baseEntity))
            {
                baseEntity.Kill();
            }
            else
            {
                GameManager.Destroy(gameObject);
            }
            return(null);
        }
        DecayEntity decayEntity = baseEntity as DecayEntity;

        if ((bool)decayEntity)
        {
            decayEntity.AttachToBuilding(target.entity as DecayEntity);
        }
        return(baseEntity);
    }
예제 #5
0
    public void Server_Purchase(RPCMessage msg)
    {
        if (!CanPlayerInteract(msg.player))
        {
            return;
        }
        if (!_marketplace.IsValid(true))
        {
            Debug.LogError("Marketplace is not set", this);
            return;
        }
        uint           num            = msg.read.UInt32();
        int            num2           = msg.read.Int32();
        int            num3           = msg.read.Int32();
        VendingMachine vendingMachine = BaseNetworkable.serverEntities.Find(num) as VendingMachine;

        if (vendingMachine == null || !BaseEntityEx.IsValid(vendingMachine) || num2 < 0 || num2 >= vendingMachine.sellOrders.sellOrders.Count || num3 <= 0 || base.inventory.IsFull())
        {
            return;
        }
        GetDeliveryEligibleVendingMachines(null);
        if (_deliveryEligible == null || !_deliveryEligible.Contains(num))
        {
            return;
        }
        try
        {
            _transactionActive = true;
            int num4 = deliveryFeeAmount;
            ProtoBuf.VendingMachine.SellOrder sellOrder = vendingMachine.sellOrders.sellOrders[num2];
            if (!CanPlayerAffordOrderAndDeliveryFee(msg.player, sellOrder, num3))
            {
                return;
            }
            int num5 = msg.player.inventory.Take(null, deliveryFeeCurrency.itemid, num4);
            if (num5 != num4)
            {
                Debug.LogError($"Took an incorrect number of items for the delivery fee (took {num5}, should have taken {num4})");
            }
            ClientRPCPlayer(null, msg.player, "Client_ShowItemNotice", deliveryFeeCurrency.itemid, -num4, false);
            if (!vendingMachine.DoTransaction(msg.player, num2, num3, base.inventory, _onCurrencyRemovedCached, _onItemPurchasedCached))
            {
                Item item = ItemManager.CreateByItemID(deliveryFeeCurrency.itemid, num4, 0uL);
                if (!msg.player.inventory.GiveItem(item))
                {
                    item.Drop(msg.player.inventory.containerMain.dropPosition, msg.player.inventory.containerMain.dropVelocity);
                }
            }
            else
            {
                RestrictToPlayer(msg.player);
                RegisterOrder(msg.player, vendingMachine);
            }
        }
        finally
        {
            _transactionActive = false;
        }
    }
예제 #6
0
        public static void status(Arg arg)
        {
            string @string = arg.GetString(0);
            string text    = string.Empty;

            if (@string.Length == 0)
            {
                text  = text + "hostname: " + Server.hostname + "\n";
                text  = text + "version : " + 2306 + " secure (secure mode enabled, connected to Steam3)\n";
                text  = text + "map     : " + Server.level + "\n";
                text += $"players : {BasePlayer.activePlayerList.Count()} ({Server.maxplayers} max) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Queued} queued) ({SingletonComponent<ServerMgr>.Instance.connectionQueue.Joining} joining)\n\n";
            }
            TextTable textTable = new TextTable();

            textTable.AddColumn("id");
            textTable.AddColumn("name");
            textTable.AddColumn("ping");
            textTable.AddColumn("connected");
            textTable.AddColumn("addr");
            textTable.AddColumn("owner");
            textTable.AddColumn("violation");
            textTable.AddColumn("kicks");
            foreach (BasePlayer activePlayer in BasePlayer.activePlayerList)
            {
                try
                {
                    if (!BaseEntityEx.IsValid(activePlayer))
                    {
                        continue;
                    }
                    string userIDString = activePlayer.UserIDString;
                    if (activePlayer.net.connection == null)
                    {
                        textTable.AddRow(userIDString, "NO CONNECTION");
                        continue;
                    }
                    string text2 = activePlayer.net.connection.ownerid.ToString();
                    string text3 = activePlayer.displayName.QuoteSafe();
                    string text4 = Network.Net.sv.GetAveragePing(activePlayer.net.connection).ToString();
                    string text5 = activePlayer.net.connection.ipaddress;
                    string text6 = activePlayer.violationLevel.ToString("0.0");
                    string text7 = activePlayer.GetAntiHackKicks().ToString();
                    if (!arg.IsAdmin && !arg.IsRcon)
                    {
                        text5 = "xx.xxx.xx.xxx";
                    }
                    string text8 = activePlayer.net.connection.GetSecondsConnected() + "s";
                    if (@string.Length <= 0 || text3.Contains(@string, CompareOptions.IgnoreCase) || userIDString.Contains(@string) || text2.Contains(@string) || text5.Contains(@string))
                    {
                        textTable.AddRow(userIDString, text3, text4, text8, text5, (text2 == userIDString) ? string.Empty : text2, text6, text7);
                    }
                }
                catch (Exception ex)
                {
                    textTable.AddRow(activePlayer.UserIDString, ex.Message.QuoteSafe());
                }
            }
            arg.ReplyWith(text + textTable.ToString());
        }
예제 #7
0
		protected override bool ShouldAdd(JunkPileWater entity)
		{
			if (base.ShouldAdd(entity))
			{
				return BaseEntityEx.IsValid(entity);
			}
			return false;
		}
예제 #8
0
 public void LockLock(BasePlayer player)
 {
     SetFlag(Flags.Locked, true);
     if (BaseEntityEx.IsValid(player))
     {
         player.GiveAchievement("LOCK_LOCK");
     }
 }
예제 #9
0
 protected override bool ShouldAdd(GrowableEntity entity)
 {
     if (base.ShouldAdd(entity))
     {
         return(BaseEntityEx.IsValid(entity));
     }
     return(false);
 }
예제 #10
0
 public static void DestroyImmediate(GameObject instance, bool allowDestroyingAssets = false)
 {
     if (BaseEntityEx.IsValid(instance.GetComponent <BaseEntity>()))
     {
         Debug.LogError("Trying to destroy an entity without killing it first: " + instance.name);
     }
     Object.DestroyImmediate(instance, allowDestroyingAssets);
 }
예제 #11
0
 protected override bool ShouldAdd(FlameTurret entity)
 {
     if (base.ShouldAdd(entity))
     {
         return(BaseEntityEx.IsValid(entity));
     }
     return(false);
 }
예제 #12
0
 public static void Destroy(Component component, float delay = 0f)
 {
     if (BaseEntityEx.IsValid(component as BaseEntity))
     {
         Debug.LogError("Trying to destroy an entity without killing it first: " + component.name);
     }
     Object.Destroy(component, delay);
 }
예제 #13
0
 public static void DestroyImmediate(Component component, bool allowDestroyingAssets = false)
 {
     if (BaseEntityEx.IsValid(component as BaseEntity))
     {
         Debug.LogError("Trying to destroy an entity without killing it first: " + component.name);
     }
     Object.DestroyImmediate(component, allowDestroyingAssets);
 }
예제 #14
0
        public static void ImpactEffect(HitInfo info)
        {
            if (!info.DoHitEffects)
            {
                return;
            }
            string materialName = StringPool.Get(info.HitMaterial);
            string strName      = EffectDictionary.GetParticle(info.damageTypes.GetMajorityDamageType(), materialName);
            string decal        = EffectDictionary.GetDecal(info.damageTypes.GetMajorityDamageType(), materialName);

            if (TerrainMeta.WaterMap != null && info.HitMaterial != Projectile.WaterMaterialID() && info.HitMaterial != Projectile.FleshMaterialID() && info.HitPositionWorld.y < TerrainMeta.WaterMap.GetHeight(info.HitPositionWorld) && WaterLevel.Test(info.HitPositionWorld, false))
            {
                return;
            }
            if (BaseEntityEx.IsValid(info.HitEntity))
            {
                GameObjectRef impactEffect = info.HitEntity.GetImpactEffect(info);
                if (impactEffect.isValid)
                {
                    strName = impactEffect.resourcePath;
                }
                Run(strName, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                if (info.DoDecals)
                {
                    Run(decal, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                }
            }
            else
            {
                Type overrideType = Type.Generic;
                Run(strName, info.HitPositionWorld, info.HitNormalWorld, default(Vector3), overrideType);
                Run(decal, info.HitPositionWorld, info.HitNormalWorld, default(Vector3), overrideType);
            }
            if ((bool)info.WeaponPrefab)
            {
                BaseMelee baseMelee = info.WeaponPrefab as BaseMelee;
                if (baseMelee != null)
                {
                    string strikeEffectPath = baseMelee.GetStrikeEffectPath(materialName);
                    if (BaseEntityEx.IsValid(info.HitEntity))
                    {
                        Run(strikeEffectPath, info.HitEntity, info.HitBone, info.HitPositionLocal, info.HitNormalLocal);
                    }
                    else
                    {
                        Run(strikeEffectPath, info.HitPositionWorld, info.HitNormalWorld);
                    }
                }
            }
            if (info.damageTypes.Has(DamageType.Explosion))
            {
                DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/explosion.prefab");
            }
            if (info.damageTypes.Has(DamageType.Heat))
            {
                DoAdditiveImpactEffect(info, "assets/bundled/prefabs/fx/impacts/additive/fire.prefab");
            }
        }
예제 #15
0
 public void Set(BaseEntity ent)
 {
     ent_cached = ent;
     id_cached  = 0u;
     if (BaseEntityEx.IsValid(ent_cached))
     {
         id_cached = ent_cached.net.ID;
     }
 }
예제 #16
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.corpse = Facepunch.Pool.Get <Corpse>();
     if (BaseEntityEx.IsValid(parentEnt))
     {
         info.msg.corpse.parentID = parentEnt.net.ID;
     }
 }
예제 #17
0
    public StorageContainer GetFuelContainer()
    {
        BaseEntity baseEntity = fuelStorageInstance.Get(isServer);

        if (baseEntity != null && BaseEntityEx.IsValid(baseEntity))
        {
            return(baseEntity as StorageContainer);
        }
        return(null);
    }
예제 #18
0
    public CardTable GetCardTable()
    {
        BaseEntity baseEntity = cardTableRef.Get(base.isServer);

        if (baseEntity != null && BaseEntityEx.IsValid(baseEntity))
        {
            return(baseEntity as CardTable);
        }
        return(null);
    }
예제 #19
0
    public StorageContainer GetPot()
    {
        BaseEntity baseEntity = PotInstance.Get(true);

        if (baseEntity != null && BaseEntityEx.IsValid(baseEntity))
        {
            return(baseEntity as StorageContainer);
        }
        return(null);
    }
예제 #20
0
        public CardTablePlayerStorage GetStorage()
        {
            BaseEntity baseEntity = storageInstance.Get(true);

            if (baseEntity != null && BaseEntityEx.IsValid(baseEntity))
            {
                return(baseEntity as CardTablePlayerStorage);
            }
            return(null);
        }
예제 #21
0
 public static void DoAdditiveImpactEffect(HitInfo info, string effectName)
 {
     if (BaseEntityEx.IsValid(info.HitEntity))
     {
         Run(effectName, info.HitEntity, info.HitBone, info.HitPositionLocal + info.HitNormalLocal * 0.1f, info.HitNormalLocal);
     }
     else
     {
         Run(effectName, info.HitPositionWorld + info.HitNormalWorld * 0.1f, info.HitNormalWorld);
     }
 }
예제 #22
0
 public static void Destroy(GameObject instance, float delay = 0f)
 {
     if ((bool)instance)
     {
         if (BaseEntityEx.IsValid(instance.GetComponent <BaseEntity>()))
         {
             Debug.LogError("Trying to destroy an entity without killing it first: " + instance.name);
         }
         Object.Destroy(instance, delay);
     }
 }
예제 #23
0
 public override void Save(SaveInfo info)
 {
     base.Save(info);
     info.msg.cassette                = Facepunch.Pool.Get <ProtoBuf.Cassette>();
     info.msg.cassette.audioId        = AudioId;
     info.msg.cassette.creatorSteamId = CreatorSteamId;
     info.msg.cassette.preloadAudioId = preloadedAudioId;
     if (!ObjectEx.IsUnityNull(currentCassettePlayer) && BaseEntityEx.IsValid(currentCassettePlayer.ToBaseEntity))
     {
         info.msg.cassette.holder = currentCassettePlayer.ToBaseEntity.net.ID;
     }
 }
예제 #24
0
    internal void OnDeployed(BaseEntity ent, BasePlayer player)
    {
        if (BaseEntityEx.IsValid(player) && !string.IsNullOrEmpty(UnlockAchievement))
        {
            player.GiveAchievement(UnlockAchievement);
        }
        BuildingPrivlidge buildingPrivlidge;

        if ((object)(buildingPrivlidge = ent as BuildingPrivlidge) != null && Interface.CallHook("OnCupboardAuthorize", buildingPrivlidge, player) == null)
        {
            buildingPrivlidge.AddPlayer(player);
        }
    }
예제 #25
0
 protected void BroadcastValueChange()
 {
     if (BaseEntityEx.IsValid(this))
     {
         EntityTarget target       = GetTarget();
         AppBroadcast appBroadcast = Facepunch.Pool.Get <AppBroadcast>();
         appBroadcast.entityChanged          = Facepunch.Pool.Get <AppEntityChanged>();
         appBroadcast.entityChanged.entityId = net.ID;
         appBroadcast.entityChanged.payload  = Facepunch.Pool.Get <AppEntityPayload>();
         FillEntityPayload(appBroadcast.entityChanged.payload);
         CompanionServer.Server.Broadcast(target, appBroadcast);
     }
 }
예제 #26
0
    public static void Send(Effect effect)
    {
        if (Net.sv == null || !Net.sv.IsConnected())
        {
            return;
        }
        using (TimeWarning.New("EffectNetwork.Send"))
        {
            Group group = null;
            if (!string.IsNullOrEmpty(effect.pooledString))
            {
                effect.pooledstringid = StringPool.Get(effect.pooledString);
            }
            if (effect.pooledstringid == 0)
            {
                Debug.Log("String ID is 0 - unknown effect " + effect.pooledString);
                return;
            }
            if (effect.broadcast)
            {
                if (Net.sv.write.Start())
                {
                    Net.sv.write.PacketID(Message.Type.Effect);
                    effect.WriteToStream(Net.sv.write);
                    Net.sv.write.Send(new SendInfo(BaseNetworkable.GlobalNetworkGroup.subscribers));
                }
                return;
            }
            if (effect.entity != 0)
            {
                BaseEntity baseEntity = BaseNetworkable.serverEntities.Find(effect.entity) as BaseEntity;
                if (!BaseEntityEx.IsValid(baseEntity))
                {
                    return;
                }
                group = baseEntity.net.group;
                goto IL_0113;
            }
            group = Net.sv.visibility.GetGroup(effect.worldPos);
            goto IL_0113;
IL_0113:
            if (group != null)
            {
                Net.sv.write.Start();
                Net.sv.write.PacketID(Message.Type.Effect);
                effect.WriteToStream(Net.sv.write);
                Net.sv.write.Send(new SendInfo(group.subscribers));
            }
        }
    }
예제 #27
0
    public static void ProcessQueue()
    {
        float realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup;
        float num = framebudgetms / 1000f;

        while (_processQueue.Count > 0 && UnityEngine.Time.realtimeSinceStartup < realtimeSinceStartup + num && !_processQueue.Peek().HasBlockedUpdatedOutputsThisFrame)
        {
            IOEntity iOEntity = _processQueue.Dequeue();
            if (BaseEntityEx.IsValid(iOEntity))
            {
                iOEntity.UpdateOutputs();
            }
        }
    }
예제 #28
0
 public void Init(Type fxtype, BaseEntity ent, uint boneID, Vector3 posLocal, Vector3 normLocal, Connection sourceConnection = null)
 {
     Clear();
     type       = (uint)fxtype;
     attached   = true;
     origin     = posLocal;
     normal     = normLocal;
     gameObject = null;
     Up         = Vector3.zero;
     if (ent != null && !BaseEntityEx.IsValid(ent))
     {
         Debug.LogWarning("Effect.Init - invalid entity");
     }
     entity = (BaseEntityEx.IsValid(ent) ? ent.net.ID : 0u);
     source = sourceConnection?.userid ?? 0;
     bone   = boneID;
 }
예제 #29
0
 private void Update()
 {
     if (!BaseEntityEx.IsValid(base.baseEntity) || !base.baseEntity.IsDebugging())
     {
         base.enabled = false;
     }
     else if (!(stopwatch.Elapsed.TotalSeconds < 0.5))
     {
         bool isClient = base.baseEntity.isClient;
         if (base.baseEntity.isServer)
         {
             base.baseEntity.DebugServer(1, (float)stopwatch.Elapsed.TotalSeconds);
         }
         stopwatch.Reset();
         stopwatch.Start();
     }
 }
예제 #30
0
 public void SetWorldEntity(BaseEntity ent)
 {
     if (!BaseEntityEx.IsValid(ent))
     {
         worldEnt.Set(null);
         MarkDirty();
     }
     else if (worldEnt.uid != ent.net.ID)
     {
         worldEnt.Set(ent);
         MarkDirty();
         OnMovedToWorld();
         if (contents != null)
         {
             contents.OnMovedToWorld();
         }
     }
 }