public void ReplacePlayerInventory(Features.Components.Inventory newValue) { var index = GameComponentsLookup.PlayerInventory; var component = (Features.Components.PlayerInventoryComponent)CreateComponent(index, typeof(Features.Components.PlayerInventoryComponent)); component.Value = newValue; ReplaceComponent(index, component); }
public GameEntity SetPlayerInventory(Features.Components.Inventory newValue) { if (hasPlayerInventory) { throw new Entitas.EntitasException("Could not set PlayerInventory!\n" + this + " already has an entity with Features.Components.PlayerInventoryComponent!", "You should check if the context already has a playerInventoryEntity before setting it or use context.ReplacePlayerInventory()."); } var entity = CreateEntity(); entity.AddPlayerInventory(newValue); return(entity); }
public void ReplacePlayerInventory(Features.Components.Inventory newValue) { var entity = playerInventoryEntity; if (entity == null) { entity = SetPlayerInventory(newValue); } else { entity.ReplacePlayerInventory(newValue); } }