Esempio n. 1
0
        public async Task SpawnEntity(string name, Entity.EntityType type, string prefabName, Vector3 position, Faction faction)
        {
            var newId = await _gameServerConnection.SendRequest <Eleon.Modding.Id>(Eleon.Modding.CmdId.Request_NewEntityId, null);

            var spawnInfo = new Eleon.Modding.EntitySpawnInfo();

            spawnInfo.forceEntityId = newId.id;
            spawnInfo.playfield     = this.Name;
            spawnInfo.pos           = position.ToPVector3();
            spawnInfo.rot           = new Eleon.Modding.PVector3();
            spawnInfo.name          = name;
            spawnInfo.type          = (byte)type;
            spawnInfo.prefabName    = prefabName;
            spawnInfo.factionGroup  = faction.Origin;
            spawnInfo.factionId     = faction.Id;
            //spawnInfo.exportedEntityDat = exportFile;

            await _gameServerConnection.SendRequest(Eleon.Modding.CmdId.Request_Entity_Spawn, spawnInfo);
        }
Esempio n. 2
0
        public async Task SpawnEntity(string name, Entity.EntityType type, string prefabName, Vector3 position, Player player)
        {
            var newId = await _gameServerConnection.SendRequest <Eleon.Modding.Id>(Eleon.Modding.CmdId.Request_NewEntityId, null);

            var spawnInfo = new Eleon.Modding.EntitySpawnInfo();

            spawnInfo.forceEntityId = newId.id;
            spawnInfo.playfield     = this.Name;
            spawnInfo.pos           = position.ToPVector3();
            spawnInfo.rot           = new Eleon.Modding.PVector3();
            spawnInfo.name          = name;
            spawnInfo.type          = (byte)type;
            spawnInfo.prefabName    = prefabName;
            spawnInfo.factionGroup  = player.FactionGroupId;
            spawnInfo.factionId     = player.EntityId;
            //spawnInfo.exportedEntityDat = exportFile;

            _gameServerConnection.DebugOutput("Creating entity for '{0}' of faction group '{1}', entity id '{2}' ", player, spawnInfo.factionGroup, spawnInfo.factionId);

            await _gameServerConnection.SendRequest(Eleon.Modding.CmdId.Request_Entity_Spawn, spawnInfo);
        }
        public void EntitySpawn(string ID, string prefabName, string exportFile, string Playfield, string entityTypeName, string name, string factionGroup, string factionID, string type, string NS, string Height, string EW, string X, string Y, string Z, string prefabDir)
        {
            try
            {
                if (prefabName == "")
                {
                    prefabName = null;
                }
                if (exportFile == "")
                {
                    exportFile = null;
                }
                if (Playfield == "")
                {
                    Playfield = null;
                }
                if (entityTypeName == "")
                {
                    entityTypeName = null;
                }
                if (name == "")
                {
                    name = null;
                }
                if (factionGroup == "")
                {
                    factionGroup = null;
                }
                if (factionID == "")
                {
                    factionID = null;
                }
                if (NS == "")
                {
                    NS = null;
                }
                if (Height == "")
                {
                    Height = null;
                }
                if (EW == "")
                {
                    EW = null;
                }
                if (X == "")
                {
                    X = null;
                }
                if (Y == "")
                {
                    Y = null;
                }
                if (Z == "")
                {
                    Z = null;
                }
                if (prefabDir == "")
                {
                    prefabDir = null;
                }
                if (type == "")
                {
                    type = null;
                }

                Eleon.Modding.EntitySpawnInfo spawnInfo;
                spawnInfo = new Eleon.Modding.EntitySpawnInfo();
                spawnInfo.forceEntityId     = System.Convert.ToInt32(ID);
                spawnInfo.exportedEntityDat = exportFile;
                spawnInfo.prefabName        = prefabName;
                spawnInfo.prefabDir         = prefabDir;
                spawnInfo.playfield         = Playfield;
                spawnInfo.name = name;
                if (factionGroup != null)
                {
                    spawnInfo.factionGroup = byte.Parse(factionGroup);
                }
                if (factionID != null)
                {
                    spawnInfo.factionId = int.Parse(factionID);
                }
                if (NS != null && Height != null && EW != null)
                {
                    spawnInfo.pos = new Eleon.Modding.PVector3(int.Parse(NS), int.Parse(Height), int.Parse(EW));
                }
                if (X != null && Y != null && Z != null)
                {
                    spawnInfo.rot = new Eleon.Modding.PVector3(int.Parse(X), int.Parse(Y), int.Parse(Z));
                }
                if (type != null)
                {
                    spawnInfo.type = byte.Parse(type);
                }
                spawnInfo.entityTypeName = entityTypeName;

                SendRequest(Eleon.Modding.CmdId.Request_Entity_Spawn, Eleon.Modding.CmdId.Request_Entity_Spawn, spawnInfo);
            }
            catch (Exception ex)
            {
                output(string.Format("Exception: {0}", ex.Message), Eleon.Modding.CmdId.Event_Error);
            }
        }