Beispiel #1
0
            /// <summary>
            /// Connects references that were stored with the player.
            /// </summary>
            public void ConnectReferences()
            {
                foreach (var unitID in storedPlayer.UnitIDs)
                {
                    loadingPlayer.AddUnitImpl(level.GetUnit(unitID));
                }

                foreach (var buildingID in storedPlayer.BuildingIDs)
                {
                    loadingPlayer.AddBuildingImpl(level.GetBuilding(buildingID));
                }

                foreach (var resource in storedPlayer.Resources)
                {
                    ResourceType resourceType = level.PackageManager.ActivePackage.GetResourceType(resource.Id);
                    loadingPlayer.resources.Add(resourceType, resource.Amount);
                }

                //If the stored data is from the same plugin type as the new type, load the data
                // otherwise we created new fresh plugin instance, that most likely does not understand the stored data
                if (type.ID == storedPlayer.TypeID)
                {
                    loadingPlayer.Plugin?.LoadState(new PluginDataWrapper(storedPlayer.UserPlugin, level));
                }
                else
                {
                    loadingPlayer.Plugin?.Init(level);
                }
            }
Beispiel #2
0
            /// <summary>
            /// Continues loading by connecting references
            /// </summary>
            public void ConnectReferences()
            {
                Tile.Type = level.Package.GetTileType(storedTile.TileTypeID);

                if (storedTile.UnitIDs.Count != 0)
                {
                    Tile.units = new List <IUnit>();
                }

                foreach (var unit in storedTile.UnitIDs)
                {
                    Tile.units.Add(level.GetUnit(unit));
                }


                if (storedTile.BuildingID != 0)
                {
                    Tile.Building = level.GetBuilding(storedTile.BuildingID);
                }
            }