Пример #1
0
        public static Entity CreateOrUpdate(UInt32 networkOrder, ProtoBuf.Entity entityInfo)
        {
            uint uid = entityInfo.baseNetworkable.uid;

            if (Has(uid))
            {
                Entity entity;
                lock (entities) {
                    entity = entities[uid];
                }
                entity.networkOrder = networkOrder;
                entity.proto        = entityInfo;
                lock (entities) {
                    entities[uid] = entity;
                }
                return(entity);
            }
            else
            {
                Entity entity = new Entity();
                entity.networkOrder = networkOrder;
                entity.proto        = entityInfo;
                lock (entities) {
                    entities.Add(uid, entity);
                }
                return(entity);
            }
        }
Пример #2
0
        public static uint ParseEntity(Packet p, out ProtoBuf.Entity entity)
        {
            /* Entity Number/Order */
            var num = p.UInt32();

            entity = ProtoBuf.Entity.Deserialize(p);
            return(num);
        }
Пример #3
0
        public override void GetEntityProtobuf(ProtoBuf.Entity entity)
        {
            base.GetEntityProtobuf(entity);

            entity.heldEntity = new ProtoBuf.HeldEntity
            {
                itemUID = this.ItemOwner?.UID ?? 0
            };
        }
Пример #4
0
        // Override because we need get ListViewToMe from owner player, not our ListViewToMe
        public override void SendNetworkUpdate(ProtoBuf.Entity _entity = null)
        {
            if (this.PlayerOwner != null && this.PlayerOwner.IsConnected)
            {
                this.SendNetworkUpdate(new SendInfo(this.PlayerOwner.Network.NetConnection), _entity);
            }

            if ((this.PlayerOwner?.ListViewToMe.Count ?? 0) != 0)
            {
                this.SendNetworkUpdate(new SendInfo(this.PlayerOwner.ListViewToMe.ToConnectionsList()), _entity);
            }
        }
Пример #5
0
        public Entity(ProtoBuf.Entity proto)
        {
            protobuf = proto;
            if (proto.basePlayer != null)
            {
                player = new BasePlayer(proto.basePlayer);
            }
            if (proto.resource != null)
            {
                resource = new BaseResource(proto.resource);
            }
            if (proto.buildingBlock != null)
            {
                buildingBlock = new BaseBuildingBlock(proto.buildingBlock);
            }
            if (proto.worldItem != null)
            {
                worldItem = new BaseItem(proto.worldItem.item);
            }
            if (proto.environment != null)
            {
                environment = new BaseEnvironment(proto.environment);
            }
            if (proto.codeLock != null)
            {
                codeLock = new BaseCodeLock(proto.codeLock);
            }
            if (proto.buildingPrivilege != null)
            {
                buildingPrivilege = new BaseBuildingPrivilege(proto.buildingPrivilege);
            }
            if (proto.storageBox != null)
            {
                storageBoxContents = new BaseItem.BaseItemContainer(proto.storageBox.contents);
            }
            if (proto.baseProjectile != null)
            {
                projectile = new BaseProjectile(proto.baseProjectile);
            }

            if (IsPlayer)
            {
                players.Add(this);
            }
        }
Пример #6
0
        public static uint CreateOrUpdate(Packet p)
        {
            /* Entity Number/Order, for internal use */
            var num = p.UInt32();

            ProtoBuf.Entity proto = global::ProtoBuf.Entity.Deserialize(p);

            /* All Networkables have Unique Identifiers */
            var id = proto.baseNetworkable.uid;

            if (CheckEntity(id))
            {
                entities[id].protobuf = proto;
            }
            else
            {
                entities[id]     = new Entity(proto);
                entities[id].num = num;
            }
            return(id);
        }