Exemplo n.º 1
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World          world        = GameManager.Instance.World;
            EntityPlayer   entityPlayer = world.Players.dict[sender.entityId];
            Vector3        position     = entityPlayer.position;
            PrefabInstance prefab       = world.GetPOIAtPosition(position);

            // If no arguments just show POI info
            if (arguments.Count == 0)
            {
                if (prefab == null)
                {
                    ChatManager.Message(sender, "[FF0000]No POI found!");
                }
                else
                {
                    ChatManager.Message(sender, string.Format("[FFCC00]POI: [DDDDDD]{0}", prefab.name));
                }
                return(false);
            }

            // Fix everything around player
            int num  = World.toChunkXZ((int)position.x) - 1;
            int num2 = World.toChunkXZ((int)position.z) - 1;
            int num3 = num + 2;
            int num4 = num2 + 2;

            HashSetLong hashSetLong = new HashSetLong();

            for (int k = num; k <= num3; k++)
            {
                for (int l2 = num2; l2 <= num4; l2++)
                {
                    hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                }
            }

            ChunkCluster chunkCache = world.ChunkCache;
            ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

            foreach (long key in hashSetLong)
            {
                if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                {
                    ChatManager.Message(sender, string.Format("Failed regenerating chunk at position {0}/{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                }
            }

            world.m_ChunkManager.ResendChunksToClients(hashSetLong);

            if (prefab != null)
            {
                prefab.Reset(world);
            }

            ChatManager.Message(sender, "[44FF44]Reseted");
            return(false);
        }
Exemplo n.º 2
0
            static bool Prefix(ObjectiveRandomPOIGoto __instance, ref Vector3 __result, ref EntityNPC ownerNPC, ref List <Vector2> usedPOILocations, ref int entityIDforQuests)
            {
                if (__instance.OwnerQuest.GetPositionData(out __instance.position, Quest.PositionDataTypes.POIPosition))
                {
                    __instance.OwnerQuest.Position = __instance.position;
                    Vector3 distanceOffset;
                    __instance.OwnerQuest.GetPositionData(out distanceOffset, Quest.PositionDataTypes.POISize);
                    __instance.SetDistanceOffset(distanceOffset);
                    __instance.positionSet = true;
                    __instance.OwnerQuest.HandleMapObject(Quest.PositionDataTypes.POIPosition, __instance.icon);
                    __instance.CurrentValue = 2;
                    __result = __instance.position;
                    return(false);
                }
                EntityAlive entityAlive = (!(ownerNPC == null)) ? ownerNPC : __instance.OwnerQuest.OwnerJournal.OwnerPlayer as EntityAlive;

                if (Steam.Network.IsServer)
                {
                    PrefabInstance randomPOINearWorldPos = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetRandomPOINearWorldPos(new Vector2(entityAlive.position.x, entityAlive.position.z), 1000, 50000000, __instance.OwnerQuest.QuestTags, __instance.OwnerQuest.QuestClass.DifficultyTier, usedPOILocations, entityIDforQuests);
                    if (randomPOINearWorldPos != null)
                    {
                        Vector2 vector = new Vector2((float)randomPOINearWorldPos.boundingBoxPosition.x + (float)randomPOINearWorldPos.boundingBoxSize.x / 2f, (float)randomPOINearWorldPos.boundingBoxPosition.z + (float)randomPOINearWorldPos.boundingBoxSize.z / 2f);
                        if (vector.x == -0.1f && vector.y == -0.1f)
                        {
                            Log.Error("ObjectiveRandomGoto: No POI found.");
                            __result = Vector3.zero;
                            return(false);
                        }
                        int num  = (int)vector.x;
                        int num2 = (int)entityAlive.position.y;
                        int num3 = (int)vector.y;
                        __instance.position = new Vector3((float)num, (float)num2, (float)num3);
                        if (GameManager.Instance.World.IsPositionInBounds(__instance.position))
                        {
                            __instance.OwnerQuest.Position = __instance.position;
                            __instance.FinalizePoint(new Vector3((float)randomPOINearWorldPos.boundingBoxPosition.x, (float)randomPOINearWorldPos.boundingBoxPosition.y, (float)randomPOINearWorldPos.boundingBoxPosition.z), new Vector3((float)randomPOINearWorldPos.boundingBoxSize.x, (float)randomPOINearWorldPos.boundingBoxSize.y, (float)randomPOINearWorldPos.boundingBoxSize.z));
                            __instance.OwnerQuest.QuestPrefab = randomPOINearWorldPos;
                            string text = Localization.Get(__instance.OwnerQuest.QuestPrefab.filename, string.Empty);
                            __instance.OwnerQuest.DataVariables.Add("POIName", string.IsNullOrEmpty(text) ? __instance.OwnerQuest.QuestPrefab.filename : text);
                            if (usedPOILocations != null)
                            {
                                usedPOILocations.Add(new Vector2((float)randomPOINearWorldPos.boundingBoxPosition.x, (float)randomPOINearWorldPos.boundingBoxPosition.z));
                            }
                            __instance.OwnerQuest.HandleMapObject(Quest.PositionDataTypes.POIPosition, __instance.icon);
                            __result = __instance.position;
                            return(false);
                        }
                    }
                }
                else
                {
                    SingletonMonoBehaviour <ConnectionManager> .Instance.SendToServer(new NetPackageQuestGotoPoint(entityAlive.entityId, __instance.OwnerQuest.QuestTags, __instance.OwnerQuest.QuestCode, NetPackageQuestGotoPoint.QuestGotoTypes.RandomPOI, __instance.OwnerQuest.QuestClass.DifficultyTier, 0, -1, 0f, 0f, 0f, -1f), false);

                    __instance.CurrentValue = 1;
                }
                __result = Vector3.zero;
                return(false);
            }
Exemplo n.º 3
0
    protected override Vector3 GetPosition(EntityNPC ownerNPC, List <Vector2> usedPOILocations, int entityIDforQuests)
    {
        if (base.OwnerQuest.GetPositionData(out this.position, Quest.PositionDataTypes.POIPosition))
        {
            base.OwnerQuest.Position = this.position;
            Vector3 distanceOffset;
            base.OwnerQuest.GetPositionData(out distanceOffset, Quest.PositionDataTypes.POISize);
            this.SetDistanceOffset(distanceOffset);
            this.positionSet = true;
            base.OwnerQuest.HandleMapObject(Quest.PositionDataTypes.POIPosition, this.icon);
            base.CurrentValue = 2;
            return(this.position);
        }

        EntityAlive entityAlive = ownerNPC;

        if (ownerNPC == null)
        {
            entityAlive = base.OwnerQuest.OwnerJournal.OwnerPlayer;
        }
        if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
        {
            //PrefabInstance randomPOINearWorldPos = GetRandomPOINearWorldPos(new Vector2(entityAlive.position.x, entityAlive.position.z), 1000, 50000000, base.OwnerQuest.QuestTags, base.OwnerQuest.QuestClass.DifficultyTier, usedPOILocations, entityIDforQuests);
            PrefabInstance randomPOINearWorldPos = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetPOIPrefabs().Find(instance => instance.filename == this.strPOIname);
            if (randomPOINearWorldPos != null)
            {
                Vector2 vector = new Vector2((float)randomPOINearWorldPos.boundingBoxPosition.x + (float)randomPOINearWorldPos.boundingBoxSize.x / 2f, (float)randomPOINearWorldPos.boundingBoxPosition.z + (float)randomPOINearWorldPos.boundingBoxSize.z / 2f);
                if (vector.x == -0.1f && vector.y == -0.1f)
                {
                    return(Vector3.zero);
                }
                int num  = (int)vector.x;
                int num2 = (int)entityAlive.position.y;
                int num3 = (int)vector.y;
                this.position = new Vector3((float)num, (float)num2, (float)num3);
                if (GameManager.Instance.World.IsPositionInBounds(this.position))
                {
                    base.OwnerQuest.Position = this.position;
                    base.FinalizePoint(new Vector3((float)randomPOINearWorldPos.boundingBoxPosition.x, (float)randomPOINearWorldPos.boundingBoxPosition.y, (float)randomPOINearWorldPos.boundingBoxPosition.z), new Vector3((float)randomPOINearWorldPos.boundingBoxSize.x, (float)randomPOINearWorldPos.boundingBoxSize.y, (float)randomPOINearWorldPos.boundingBoxSize.z));
                    base.OwnerQuest.QuestPrefab = randomPOINearWorldPos;
                    base.OwnerQuest.DataVariables.Add("POIName", base.OwnerQuest.QuestPrefab.filename);
                    if (usedPOILocations != null)
                    {
                        usedPOILocations.Add(new Vector2((float)randomPOINearWorldPos.boundingBoxPosition.x, (float)randomPOINearWorldPos.boundingBoxPosition.z));
                    }
                    base.OwnerQuest.HandleMapObject(Quest.PositionDataTypes.POIPosition, this.icon);
                    return(this.position);
                }
            }
        }
        else
        {
            SingletonMonoBehaviour <ConnectionManager> .Instance.SendPackage(NetPackageManager.GetPackage <NetPackageQuestGotoPoint>().Setup(entityAlive.entityId, base.OwnerQuest.QuestTags, base.OwnerQuest.QuestCode, NetPackageQuestGotoPoint.QuestGotoTypes.RandomPOI, base.OwnerQuest.QuestClass.DifficultyTier, 0, -1, 0f, 0f, 0f, -1), false);

            base.CurrentValue = 1;
        }
        return(Vector3.zero);
    }
Exemplo n.º 4
0
        IAdaptable IResourceConverter.Convert(IResource resource)
        {
            Prefab prefab = resource as Prefab;

            if (prefab != null)
            {
                return(PrefabInstance.Create(prefab));
            }
            return(null);
        }
Exemplo n.º 5
0
        private void Construct(string path)
        {
            if (path == "")
            {
                return;
            }

            m_fileInfo = new FileInfo(path);
            Name       = Path.GetFileNameWithoutExtension(m_fileInfo.Name);
            Type       = FindType(m_fileInfo);

            // Data directory wasn't found. The user has to manually select the directory.
            bool updateExistingPrefabWithDirectoryId = false;

            if (Type == FileType.Unknown && PrefabInstance != null && PrefabInstance.GetComponent <AGXUnity.IO.RestoredAGXFile>() != null)
            {
                if (EditorUtility.DisplayDialog("Data directory for prefab not found",
                                                "Would you like to manually select directory for the given prefab?",
                                                "Yes", "No"))
                {
                    var dataDirectory    = EditorUtility.OpenFolderPanel("Data directory for: " + PrefabInstance.name, m_fileInfo.Directory.FullName, "");
                    var relDataDirectory = Utils.MakeRelative(dataDirectory, Application.dataPath).Replace('\\', '/');
                    if (AssetDatabase.IsValidFolder(relDataDirectory))
                    {
                        Type = FileType.AGXPrefab;
                        PrefabInstance.GetComponent <AGXUnity.IO.RestoredAGXFile>().DataDirectoryId = AssetDatabase.AssetPathToGUID(relDataDirectory);
                        updateExistingPrefabWithDirectoryId = true;
                    }
                }
            }

            RootDirectory = Utils.MakeRelative(m_fileInfo.Directory.FullName, Application.dataPath).Replace('\\', '/');
            // If the file is located in the root Assets folder the relative directory
            // is the empty string and Unity requires the relative path to include "Assets".
            if (RootDirectory == string.Empty)
            {
                RootDirectory = "Assets";
            }

            if (Type == FileType.AGXPrefab)
            {
                DataDirectory = AssetDatabase.GUIDToAssetPath(PrefabInstance.GetComponent <AGXUnity.IO.RestoredAGXFile>().DataDirectoryId);
            }
            else
            {
                DataDirectory = RootDirectory + "/" + Name + "_Data";
            }

            ExistingPrefab = AssetDatabase.LoadAssetAtPath <GameObject>(PrefabPath);
            if (ExistingPrefab && updateExistingPrefabWithDirectoryId)
            {
                ExistingPrefab.GetComponent <AGXUnity.IO.RestoredAGXFile>().DataDirectoryId = PrefabInstance.GetComponent <AGXUnity.IO.RestoredAGXFile>().DataDirectoryId;
                Save();
            }
        }
Exemplo n.º 6
0
        IGameObject IResourceConverter.Convert(IResource resource)
        {
            Prefab prefab = resource as Prefab;

            if (prefab != null)
            {
                PrefabInstance instance = PrefabInstance.Create(prefab);
                return(instance.As <IGameObject>());
            }
            return(null);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Returns true if file is an existing prefab with corresponding .agx/.aagx file.
        /// </summary>
        /// <param name="info">File info.</param>
        /// <returns>True if the .prefab file is has a corresponding .agx/.aagx file.</returns>
        public bool IsExistingAGXPrefab(FileInfo info)
        {
            if (info == null || !info.Exists || PrefabInstance == null)
            {
                return(false);
            }

            var restoredFileInfo = PrefabInstance.GetComponent <AGXUnity.IO.RestoredAGXFile>();

            return(restoredFileInfo != null &&
                   AssetDatabase.IsValidFolder(AssetDatabase.GUIDToAssetPath(restoredFileInfo.DataDirectoryId)));
        }
Exemplo n.º 8
0
        public static bool Prefix(NetPackageQuestGotoPoint __instance, World _world, string ___biomeFilter, int ___playerId, int ___questCode, QuestTags ___questTags, byte ___difficulty, Vector2 ___position, Vector3 ___size)
        {
            if (_world == null)
            {
                return(true);
            }

            // Only check if the biomeFilter is being used as a POI name
            if (String.IsNullOrEmpty(___biomeFilter))
            {
                return(true);
            }

            PrefabInstance prefabInstance = GameManager.Instance.World.ChunkClusters[0].ChunkProvider.GetDynamicPrefabDecorator().GetPOIPrefabs().Find(instance => instance.name.Contains(___biomeFilter));

            if (prefabInstance == null)
            {
                return(true);
            }

            if (SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
            {
                for (int i = 0; i < 5; i++)
                {
                    if (__instance.GotoType == NetPackageQuestGotoPoint.QuestGotoTypes.RandomPOI)
                    {
                        if (prefabInstance != null)
                        {
                            SingletonMonoBehaviour <ConnectionManager> .Instance.SendPackage(NetPackageManager.GetPackage <NetPackageQuestGotoPoint>().Setup(___playerId, ___questTags, ___questCode, __instance.GotoType, ___difficulty, prefabInstance.boundingBoxPosition.x, prefabInstance.boundingBoxPosition.z, prefabInstance.boundingBoxSize.x, prefabInstance.boundingBoxSize.y, prefabInstance.boundingBoxSize.z, -1f, BiomeFilterTypes.AnyBiome, ___biomeFilter), false, ___playerId, -1, -1, -1);

                            return(false);
                        }
                    }
                }
                return(true);
            }

            EntityPlayer primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
            Quest        quest         = primaryPlayer.QuestJournal.FindActiveQuest(___questCode);

            if (quest != null)
            {
                for (int j = 0; j < quest.Objectives.Count; j++)
                {
                    if (quest.Objectives[j] is ObjectiveRandomPOIGoto && __instance.GotoType == NetPackageQuestGotoPoint.QuestGotoTypes.RandomPOI)
                    {
                        ((ObjectiveRandomPOIGoto)quest.Objectives[j]).FinalizePoint(new Vector3(___position.x, primaryPlayer.position.y, ___position.y), ___size);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 9
0
    private PrefabInstance GetPrefabInstance(Object prefab)
    {
        foreach (var g in _Groups)
        {
            if (g.Prefab == prefab)
            {
                return(g);
            }
        }
        PrefabInstance pi = new PrefabInstance(prefab);

        _Groups.Add(pi);
        return(pi);
    }
Exemplo n.º 10
0
 public static void BakeInstance(PrefabInstance pi)
 {
     if(!pi.prefab || !pi.enabled)
         return;
     pi.enabled = false;
     GameObject go = PrefabUtility.InstantiatePrefab(pi.prefab) as GameObject;
     Quaternion rot = go.transform.localRotation;
     Vector3 scale = go.transform.localScale;
     go.transform.parent = pi.transform;
     go.transform.localPosition = Vector3.zero;
     go.transform.localScale = scale;
     go.transform.localRotation = rot;
     pi.prefab = null;
     foreach (PrefabInstance childPi in go.GetComponentsInChildren<PrefabInstance>())
         BakeInstance (childPi);
 }
Exemplo n.º 11
0
 private void Group(Transform parent)
 {
     for (int i = 0; i < parent.childCount; i++)
     {
         Transform child  = parent.GetChild(i);
         Object    prefab = PrefabUtility.GetPrefabParent(child.gameObject);
         if (prefab != null)
         {
             PrefabInstance pi = GetPrefabInstance(prefab);
             pi.Instances.Add(child);
         }
         else
         {
             Group(child);
         }
     }
 }
Exemplo n.º 12
0
            private void CheckGameObjectForPrefabs(GameObject gameObject, GameObject parentPrefabRoot, ref List <PrefabInstance> prefabInstances)
            {
                GameObject prefabRoot = PrefabUtility.GetNearestPrefabInstanceRoot(gameObject);

                if (prefabRoot != null && prefabRoot != parentPrefabRoot)
                {
                    PrefabInstance prefabInstance = new PrefabInstance
                    {
                        _gameObject = prefabRoot,
                        _prefab     = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(prefabRoot)
                    };
                    prefabInstances.Add(prefabInstance);
                    parentPrefabRoot = prefabRoot;
                }

                foreach (Transform child in gameObject.transform)
                {
                    CheckGameObjectForPrefabs(child.gameObject, parentPrefabRoot, ref prefabInstances);
                }
            }
Exemplo n.º 13
0
    public bool FindBoundsOfPrefab()
    {
        var pos = this.theEntity.position;
        prefab = GameManager.Instance.prefabLODManager.prefabsAroundNear.Values.FirstOrDefault(d => pos.x >= d.boundingBoxPosition.x && pos.x < d.boundingBoxPosition.x + d.boundingBoxSize.x && pos.z >= d.boundingBoxPosition.z && pos.z < d.boundingBoxPosition.z + d.boundingBoxSize.z);
        if (prefab == null)
        {
            DisplayLog(" I am not in a prefab. Returning false.");
            return false;
        }

        if (prefab.CheckForAnyPlayerHome(this.theEntity.world) != GameUtils.EPlayerHomeType.None)
        {
            DisplayLog(" This is a player's home. Not looting.");
            return false;
        }

        var prefabBounds = prefab.boundingBoxSize;

        return true;
    }
Exemplo n.º 14
0
    public static void BakeInstance(PrefabInstance pi)
    {
        if (!pi.prefab || !pi.enabled)
        {
            return;
        }
        pi.enabled = false;
        GameObject go    = PrefabUtility.InstantiatePrefab(pi.prefab) as GameObject;
        Quaternion rot   = go.transform.localRotation;
        Vector3    scale = go.transform.localScale;

        go.transform.parent        = pi.transform;
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale    = scale;
        go.transform.localRotation = rot;
        pi.prefab = null;
        foreach (PrefabInstance childPi in go.GetComponentsInChildren <PrefabInstance>())
        {
            BakeInstance(childPi);
        }
    }
Exemplo n.º 15
0
    public bool FindBoundsOfPrefab()
    {
        var pos = this.theEntity.position;

        FindPrefabsNear();
        prefab = FindPrefabsNear();
        if (prefab == null)
        {
            DisplayLog(" I am not in a prefab. Returning false.");
            return(false);
        }

        if (prefab.CheckForAnyPlayerHome(this.theEntity.world) != GameUtils.EPlayerHomeType.None)
        {
            DisplayLog(" This is a player's home. Not looting.");
            return(false);
        }

        var prefabBounds = prefab.boundingBoxSize;

        return(true);
    }
Exemplo n.º 16
0
 public static bool PrefabInstance_Prefix(ref PrefabInstance __instance, ref Prefab _bad)
 {
     // No longer needed, but left as an example
     return(true);
 }
Exemplo n.º 17
0
 private PrefabExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, GameObject root) :
     this(assetExporter, root.File, PrefabInstance.CreateVirtualInstance(virtualFile, root))
 {
 }
Exemplo n.º 18
0
 private PrefabExportCollection(IAssetExporter assetExporter, IAssetContainer file, PrefabInstance prefab) :
     base(assetExporter, prefab)
 {
     foreach (EditorExtension asset in prefab.FetchObjects(file))
     {
         AddAsset(asset);
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Open or create new document.
        /// It opens if the file exist otherwise it will creates new document
        /// </summary>
        public static GameDocument OpenOrCreate(Uri uri, SchemaLoader schemaLoader)
        {
            if (!uri.IsAbsoluteUri)
            {
                return(null);
            }

            var docRegistry = Globals.MEFContainer.GetExportedValue <GameDocumentRegistry>();

            GameDocument document = docRegistry.FindDocument(uri) as GameDocument;

            if (document != null)
            {
                return(document);
            }

            string filePath = uri.LocalPath;

            DomNode rootNode = null;

            if (File.Exists(filePath))
            {
                // read existing document using custom dom XML reader
                using (FileStream stream = File.OpenRead(filePath))
                {
                    var reader = new CustomDomXmlReader(Globals.ResourceRoot, schemaLoader);
                    rootNode = reader.Read(stream, uri);
                }
            }
            else
            {
                // create new document by creating a Dom node of the root type defined by the schema
                rootNode = new DomNode(Schema.gameType.Type, Schema.gameRootElement);
                rootNode.SetAttribute(Schema.gameType.nameAttribute, "Game".Localize());
            }


            GameObjectFolder rootFolder = Adapters.As <GameObjectFolder>(rootNode.GetChild(Schema.gameType.gameObjectFolderChild));

            if (rootFolder == null)
            {
                // create the game object folder
                rootFolder      = (GameObjectFolder)GameObjectFolder.Create();
                rootFolder.Name = "GameObjects".Localize("this is the name of a folder in the project lister");
                rootNode.SetChild(Schema.gameType.gameObjectFolderChild, rootFolder.DomNode);
            }


            // create bookmarks
            DomNode bookmarks = rootNode.GetChild(Schema.gameType.bookmarksChild);

            if (bookmarks == null)
            {
                bookmarks = new DomNode(Schema.bookmarksType.Type);
                rootNode.SetChild(Schema.gameType.bookmarksChild, bookmarks);
            }

            DomNode layersNode = rootNode.GetChild(Schema.gameType.layersChild);

            if (layersNode == null)
            {
                layersNode = new DomNode(Schema.layersType.Type);
                rootNode.SetChild(Schema.gameType.layersChild, layersNode);
            }

            // Create the grid
            DomNode gridNode = rootNode.GetChild(Schema.gameType.gridChild);

            if (gridNode == null)
            {
                gridNode = new DomNode(Schema.gridType.Type);
                rootNode.SetChild(Schema.gameType.gridChild, gridNode);
            }

            document     = rootNode.As <GameDocument>();
            document.Uri = uri;

            // Initialize Dom extensions now that the data is complete
            rootNode.InitializeExtensions();

            docRegistry.Add(document);


            UniqueNamer uniqueNamer = new UniqueNamer('_');

            foreach (DomNode node in rootNode.Subtree)
            {
                if (node.Type.IdAttribute != null)
                {
                    uniqueNamer.Name(node.GetId());
                }
            }


            // sync all the prefab instances
            DomNode folderNode = document.RootGameObjectFolder.As <DomNode>();

            foreach (DomNode node in folderNode.Subtree)
            {
                PrefabInstance prefab = node.As <PrefabInstance>();
                if (prefab == null)
                {
                    continue;
                }
                prefab.Resolve(uniqueNamer);
            }

            if (ResolveOnLoad)
            {
                // resovle all the game references.
                foreach (var subGame in document.GetChildList <GameReference>(Schema.gameType.gameReferenceChild))
                {
                    subGame.Resolve();
                }
            }

            document.Dirty = false;
            return(document);
        }
Exemplo n.º 20
0
        internal static void PlayerSpawnedInWorld(ClientInfo player, RespawnType respawnReason, Vector3i _pos)
        {
            string   pId         = player.playerId;
            ModState playerState = VariableContainer.GetPlayerState(pId);
            World    world       = GameManager.Instance.World;

            if (respawnReason.Equals(RespawnType.Died))
            {
                if (playerState.Equals(ModState.RECONNECTING_TO_GAME) || playerState.Equals(ModState.IN_GAME) || playerState.Equals(ModState.START_GAME))
                {
                    if (playerState.Equals(ModState.RECONNECTING_TO_GAME))
                    {
                        Team.Member member = new Team.Member
                        {
                            entityId = player.entityId,
                            nick     = player.playerName,
                            pId      = pId
                        };

                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                        TeamMaker.AddPlayerToTeam(member, VariableContainer.GetPlayerLastTeam(pId));
                    }

                    // Has no items, teleport to team spawn and give items
                    Map     map   = VariableContainer.GetMap(VariableContainer.selectedMap);
                    Vector3 spawn = TeamMaker.GetPlayerTeam(pId).spawn;

                    Log.Out(string.Format("Spawn for {0} is {1}", player.playerName, spawn.ToString()));

                    // Find random spor around spawn
                    Vector3 destination = Vector3.zero;
                    //if (!world.GetRandomSpawnPositionMinMaxToPosition(spawn, 0, 2, 2, false, out destination, true))
                    // {
                    destination = spawn;
                    //}

                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));

                    // ReGen
                    // Rebuild terrain around spawn
                    if (!refubrishedCords.Contains(spawn))
                    {
                        // But only once
                        refubrishedCords.Add(spawn);

                        PrefabInstance prefab = GameManager.Instance.World.GetPOIAtPosition(spawn);

                        int num  = World.toChunkXZ((int)spawn.x) - 1;
                        int num2 = World.toChunkXZ((int)spawn.z) - 1;
                        int num3 = num + 2;
                        int num4 = num2 + 2;

                        HashSetLong hashSetLong = new HashSetLong();
                        for (int k = num; k <= num3; k++)
                        {
                            for (int l2 = num2; l2 <= num4; l2++)
                            {
                                hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                            }
                        }

                        ChunkCluster chunkCache = world.ChunkCache;
                        ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

                        foreach (long key in hashSetLong)
                        {
                            if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                            {
                                ChatManager.Message(player, string.Format("[FF4136]Failed regenerating chunk at position [FF851B]{0}[FF4136]/[FF851B]{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                            }
                        }

                        world.m_ChunkManager.ResendChunksToClients(hashSetLong);

                        if (prefab != null)
                        {
                            prefab.Reset(world);
                        }
                    }

                    // Give items
                    ClassManager.ApplyClass(player);

                    if (VariableContainer.GetPlayerState(pId).Equals(ModState.START_GAME))
                    {
                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                    }
                    else
                    {
                        HandleDiedInGame(player);
                    }
                    return;
                }
                else
                {
                    VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
                    return;
                }
            }

            if (respawnReason.Equals(RespawnType.Teleport))
            {
                return;
            }

            if (VariableContainer.GetPlayerState(pId).Equals(ModState.RECONNECTING_TO_GAME))
            {
                // Have to kill reconected player
                Log.Out("Killing bc of reconnect: " + player.playerName);
                world.Players.dict[player.entityId].DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false, 1f);
                return;
            }

            if (VariableContainer.selectedMap == "null")
            {
                VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
            }
        }
Exemplo n.º 21
0
	// Use this for initialization
	void Start () {
		pInstance = GetComponent<PrefabInstance>();
		initSetting ();
	}
Exemplo n.º 22
0
 public static void Postfix(PrefabInstance __instance, Chunk _chunk)
 {
     WinterModPrefab.SetSnowChunk(_chunk, __instance.boundingBoxPosition, __instance.boundingBoxSize);
 }