public virtual void Load(string filename, WorldSaveData saveData) { _context.SetStore(nameof(World), this); _context.SetStore(nameof(Player), Player.Instance); if (AudioManager.Instance && World.BackgroundMusic) { AudioManager.Instance.Push(World.BackgroundMusic, 0.0f, 1.0f, 0.0f); } _variables.LoadFrom(saveData.PersistentVariables, VariableDefinition.Saved); foreach (var zoneData in saveData.Zones) { var zone = World.GetZoneByName(zoneData.Name); var data = zone != null?GetZone(zone) : null; if (data != null) { data.Load(zoneData); } } SaveFilename = filename; }
protected virtual void SetupVariables(VariableList savedVariables) { if (_propertyMap == null) { _propertyMap = new PropertyMap <Player>(); AddPropertiesToMap(_propertyMap); } if (_variableMap == null || _variableMap.Version != WorldManager.Instance.World.PlayerSchema.Version) { _variableMap = new VariableMap(WorldManager.Instance.World.PlayerSchema.Version) .Add(_propertyMap) .Add(WorldManager.Instance.World.PlayerSchema); } _variableStore.Setup(_variableMap, new PropertyList <Player>(this, _propertyMap), new VariableListener(this, _variables)); _variables.Setup(WorldManager.Instance.World.PlayerSchema, this); _variables.LoadFrom(savedVariables, VariableDefinition.Saved); }
public virtual void Load(NpcSaveData saveData) { SetupVariables(); if (saveData != null) { _variables.LoadFrom(saveData.NpcTraits, VariableDefinition.Saved); if (Controller) { Controller.Mover.WarpToPosition(saveData.Position, saveData.Direction, CollisionLayer.None); Controller.Load(saveData.ControllerData); } if (Trainer) { Trainer.Traits.LoadFrom(saveData.TrainerTraits, VariableDefinition.Saved); } } }
protected virtual void Load(CreatureSaveData data) { Name = data.Name; _learnedSkills = data.LearnedSkills; Traits.LoadFrom(data.Traits, VariableDefinition.Saved); foreach (var moveData in data.Moves) { var move = Move.Create(this, moveData); if (move != null) { Moves.Add(move); } else { Debug.LogWarningFormat(this, _missingAbilityWarning, Name); } } }
protected virtual void Load(MoveSaveData data) { Name = data.Name; Traits.LoadFrom(data.Traits, VariableDefinition.Saved); }
public virtual void Load(ZoneSaveData saveData) { _variables.LoadFrom(saveData.PersistentVariables, VariableDefinition.Saved); _npcData = saveData.Npcs.ToDictionary(npc => npc.Id); }