public static Topping ConvertToTopping(ToppingSdo sdo) { if (sdo == null) { return(null); } var topping = new Topping(sdo); return(topping); }
public static ToppingSdo ConvertToToppingSdo(Topping topping) { if (topping == null) { return(null); } var sdo = new ToppingSdo { ToppingType = topping.Type }; return(sdo); }
public Topping(ToppingSdo sdo) { Type = sdo.ToppingType; GetToppingSprites(); }
public static Entity ConvertToEntity(EntitySdo entitySdo) { Entity entity; entity = new Entity(entitySdo.Id, entitySdo.PrefabPath, entitySdo.IsPlayer); entity.PrefabPath = entitySdo.PrefabPath; entity.TotalBodyPartCoverage = entitySdo.TotalBodyPartCoverage; entity.Level = entitySdo.Level; entity.Xp = entitySdo.Xp; entity.Strength = entitySdo.Strength; entity.Agility = entitySdo.Agility; entity.Constitution = entitySdo.Constitution; entity.Intelligence = entitySdo.Intelligence; entity.MaxHp = entitySdo.MaxHp; entity.CurrentHp = entitySdo.CurrentHp; entity.Speed = entitySdo.Speed; entity.Defense = entitySdo.Defense; entity.Body = entitySdo.Body; entity.EntityType = entitySdo.EntityType; entity.Classification = entitySdo.Classification; entity.Fluff = entitySdo.Fluff; entity.Mobile = entitySdo.Mobile; entity.ToppingDropped = ToppingSdo.ConvertToTopping(entitySdo.ToppingDropped); entity.ToppingCounts = entitySdo.ToppingCounts; entity.EntityReputation = entitySdo.Reputation; entity.Abilities = new Entity.AbilityDictionary(); if (string.IsNullOrEmpty(entitySdo.CurrentCellId)) { entity.CurrentCell = null; entity.CurrentArea = null; entity.CurrentTile = null; } else { entity.CurrentCell = WorldData.Instance.MapDictionary[entitySdo.CurrentCellId]; entity.CurrentArea = entity.CurrentCell.GetAreaById(entitySdo.CurrentAreaId); entity.CurrentTile = entity.CurrentArea?.GetTileById(entitySdo.CurrentTileId); } entity.CurrentPosition = new Vector3(entitySdo.CurrentPosition.Y, entitySdo.CurrentPosition.X, entitySdo.CurrentPosition.Z); foreach (var itemId in entitySdo.InventoryItemIds) { if (itemId == Guid.Empty) { continue; } var item = WorldData.Instance.Items[itemId]; entity.Inventory.Add(item.Id, item); } foreach (var equipped in entitySdo.EquippedIds) { if (equipped.Value == Guid.Empty) { continue; } var item = WorldData.Instance.Items[equipped.Value]; if (entity.Equipped.ContainsKey(equipped.Key)) { entity.Equipped[equipped.Key] = item; } else { entity.Equipped.Add(equipped.Key, item); } } if (entitySdo.AbilityNames != null && entitySdo.AbilityNames.Count > 0) { foreach (var abilityName in entitySdo.AbilityNames) { var template = AbilityStore.GetAbilityByName(abilityName); var ability = AbilityStore.CreateAbility(template, entity); entity.Abilities.Add(abilityName, ability); } } return(entity); }
public static EntitySdo ConvertToEntitySdo(Entity entity) { EntitySdo sdo; sdo = new EntitySdo(); sdo.Id = entity.Id; sdo.IsPlayer = entity.IsPlayer(); sdo.PrefabPath = entity.PrefabPath; sdo.FactionName = entity.Faction?.Name; sdo.TotalBodyPartCoverage = entity.TotalBodyPartCoverage; sdo.CurrentPosition = entity.CurrentPosition; sdo.Level = entity.Level; sdo.Xp = entity.Xp; sdo.Strength = entity.Strength; sdo.Agility = entity.Agility; sdo.Constitution = entity.Constitution; sdo.Intelligence = entity.Intelligence; sdo.MaxHp = entity.MaxHp; sdo.CurrentHp = entity.CurrentHp; sdo.Speed = entity.Speed; sdo.Defense = entity.Defense; sdo.InventoryItemIds = new List <Guid>(); sdo.EquippedIds = new Dictionary <Entity.EquipmentSlot, Guid>(); sdo.Body = entity.Body; sdo.EntityType = entity.EntityType; sdo.Classification = entity.Classification; sdo.Fluff = entity.Fluff; sdo.CurrentCellId = entity.CurrentCell?.Id; sdo.CurrentAreaId = entity.CurrentArea?.Id; sdo.CurrentTileId = entity.CurrentTile?.Id; sdo.Mobile = entity.Mobile; sdo.ToppingDropped = ToppingSdo.ConvertToToppingSdo(entity.ToppingDropped); sdo.ToppingCounts = entity.ToppingCounts; sdo.BirthMotherId = entity.BirthMother?.Id ?? Guid.Empty; sdo.BirthFatherId = entity.BirthFather?.Id ?? Guid.Empty; sdo.ChildrenIds = new List <Guid>(); sdo.Reputation = entity.EntityReputation; sdo.AbilityNames = new List <string>(); foreach (var itemId in entity.Inventory.Keys) { sdo.InventoryItemIds.Add(itemId); } foreach (var slot in entity.Equipped.Keys) { sdo.EquippedIds.Add(new KeyValuePair <Entity.EquipmentSlot, Guid>(slot, entity.Equipped[slot]?.Id ?? Guid.Empty)); } if (entity.Children != null && entity.Children.Count > 0) { foreach (var child in entity.Children) { sdo.ChildrenIds.Add(child.Id); } } if (entity.Abilities != null && entity.Abilities.Count > 0) { foreach (var abilityName in entity.Abilities.Keys) { sdo.AbilityNames.Add(abilityName); } } return(sdo); }