コード例 #1
0
 public CellBatch(ProtoEntity stamp, int x, int y, bool isStencil)
 {
     Stamp     = stamp;
     X         = x;
     Y         = y;
     IsStencil = isStencil;
 }
コード例 #2
0
        public BitMapBatch(ProtoEntity stamp, int x, int y, bool isStencil)
            : base(stamp, x, y, isStencil)
        {
            var typeCode = Type.GetTypeCode(typeof(T));

            switch (typeCode)
            {
            case TypeCode.SByte:
            case TypeCode.Byte:
                Dimension = 8;
                break;

            case TypeCode.Int16:
            case TypeCode.UInt16:
                Dimension = 16;
                break;

            case TypeCode.Int32:
            case TypeCode.UInt32:
                Dimension = 32;
                break;

            case TypeCode.Int64:
            case TypeCode.UInt64:
                Dimension = 64;
                break;

            default:
                throw new ArgumentException(
                          "BitMapBatch can only support the following types: sbyte, byte, short, ushort, int, uint, long, ulong");
            }

            bitMap = new T[Dimension];
        }
コード例 #3
0
ファイル: FormEditor.cs プロジェクト: tws2xa/RunningGame
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Deselect any selected entities
            txtVar.Text = "";
            if (creationGame.getCurrentLevel().vars.selectedEntity != null)
            {
                creationGame.getCurrentLevel().sysManager.inputManSystem.deselectEntity();
            }

            if (creationGame.getCurrentLevel().vars.protoEntity != null)
            {
                creationGame.getCurrentLevel().removeEntity(creationGame.getCurrentLevel().vars.protoEntity);
                creationGame.getCurrentLevel().vars.protoEntity = null;
            }

            if (lstEntities.SelectedIndex != -1)
            {
                EntityListItem item = ( EntityListItem )lstEntities.Items[lstEntities.SelectedIndex];
                ProtoEntity    p    = new ProtoEntity(creationGame.getCurrentLevel(), item.myType);
                creationGame.getCurrentLevel().addEntity(p.randId, p);
                creationGame.getCurrentLevel().vars.protoEntity = p;
            }

            pnlMain.Focus();
        }
コード例 #4
0
        public void EntityImportExport()
        {
            // Ensure we have a test universe.
            _game        = TestingUtilities.CreateTestUniverse(10);
            _smAuthToken = new AuthenticationToken(_game.SpaceMaster);

            Assert.NotNull(_game);

            // Choose a random system.
            var rand = new Random();
            List <StarSystem> systems = _game.GetSystems(_smAuthToken);
            int        systemIndex    = rand.Next(systems.Count - 1);
            StarSystem system         = systems[systemIndex];

            // Export/Reinport all system bodies in that system.

            foreach (Entity entity in system.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>(_smAuthToken))
            {
                string jsonString = SerializationManager.Export(_game, entity);

                // Clone the entity for later comparison.
                ProtoEntity clone = entity.Clone();

                // Destroy the entity.
                entity.Destroy();

                // Ensure the entity was destroyed.
                Entity foundEntity;
                Assert.IsFalse(system.FindEntityByGuid(clone.Guid, out foundEntity));

                // Import the entity back into the manager.
                Entity importedEntity = SerializationManager.ImportEntityJson(_game, jsonString, system);

                // Ensure the imported entity is valid
                Assert.IsTrue(importedEntity.IsValid);
                // Check to find the guid.
                Assert.IsTrue(system.FindEntityByGuid(clone.Guid, out foundEntity));
                // Check the ID imported correctly.
                Assert.AreEqual(clone.Guid, importedEntity.Guid);
                // Check the datablobs imported correctly.
                Assert.AreEqual(clone.DataBlobs.Where(dataBlob => dataBlob != null).ToList().Count, importedEntity.DataBlobs.Count);
                // Check the manager is the same.
                Assert.AreEqual(system, importedEntity.Manager);
            }
        }
コード例 #5
0
ファイル: Server.cs プロジェクト: mqrause/Pulsar4x
        void SendFactionHash(NetConnection recipient, Entity factionEntity)
        {
            ProtoEntity factionEntityClone = factionEntity.Clone(); //clone it, then remove the AuthDB, we don't send it, so don't include the hash for it.

            factionEntityClone.RemoveDataBlob <AuthDB>();

            MemoryStream       mStream    = new MemoryStream();
            NetOutgoingMessage netMessage = NetPeerObject.CreateMessage();

            netMessage.Write((byte)ToClientMsgType.SendEntityHashData);

            List <BaseDataBlob> blobsWithValueHash = (List <BaseDataBlob>)factionEntityClone.DataBlobs.Where((arg) => arg is IGetValuesHash);

            netMessage.Write(blobsWithValueHash.Count);


            foreach (IGetValuesHash item in blobsWithValueHash)
            {
                netMessage.Write(item.GetType().ToString());
                netMessage.Write(item.GetValueCompareHash());
            }
            NetServerObject.SendMessage(netMessage, recipient, NetDeliveryMethod.ReliableOrdered);
        }
コード例 #6
0
ファイル: Server.cs プロジェクト: mqrause/Pulsar4x
        void SendFactionData(NetConnection recipient, Entity factionEntity)
        {
            //var ownedEntities = factionEntity.GetDataBlob<FactionOwnedEntitesDB>().OwnedEntites.Values.ToArray();
            ProtoEntity factionEntityClone = factionEntity.Clone(); //clone it, then remove the AuthDB, we don't want to send that.

            factionEntityClone.RemoveDataBlob <AuthDB>();

            var mStream = new MemoryStream();

            SerializationManager.Export(Game, mStream, factionEntityClone);


            byte[]             entityByteArray = mStream.ToArray();
            int                len             = entityByteArray.Length;
            NetOutgoingMessage sendMsg         = NetPeerObject.CreateMessage();

            sendMsg.Write((byte)ToClientMsgType.SendFactionEntity);
            sendMsg.Write(factionEntity.Guid.ToByteArray());
            sendMsg.Write(factionEntityClone.GetValueCompareHash());
            sendMsg.Write(len);
            sendMsg.Write(entityByteArray);
            NetServerObject.SendMessage(sendMsg, recipient, NetDeliveryMethod.ReliableOrdered);
            mStream.Close();
        }
コード例 #7
0
 public RectangularBatch(ProtoEntity stamp, int x, int y, int width, int height, bool isStencil)
     : base(stamp, x, y, isStencil)
 {
     Width  = width;
     Height = height;
 }
コード例 #8
0
 public LineBatch(ProtoEntity stamp, int x, int y, int direction, int length, bool isStencil)
     : base(stamp, x, y, isStencil)
 {
     Direction = direction;
     Length    = length;
 }
コード例 #9
0
 public SquareBatch(ProtoEntity stamp, int x, int y, int size, bool isStencil)
     : base(stamp, x, y, isStencil)
 {
     Size = size;
 }
コード例 #10
0
 public override string ToString()
 {
     return(ProtoEntity.ToString());
 }
コード例 #11
0
 public BatchTracker(ProtoEntity stamp, int x, int y)
 {
     Stamp = stamp;
     tiles.Add(new Point(x, y));
 }