public static int CreateGameEntity(Components.GameEntity entity) { EngineAPIStructs.GameEntityDescriptor desc = new EngineAPIStructs.GameEntityDescriptor(); //Transform component { var c = entity.GetComponent <Components.Transform>(); desc.Transform.Position = c.Position; desc.Transform.Rotation = c.Rotation; desc.Transform.Scale = c.Scale; } //Script component { //Check to see if current project is null, in order to tell if game code dll has been loaded. //This way, creation of entities with script component is deferred until dll has been loaded var c = entity.GetComponent <Components.Script>(); if (c != null && GameProject.Project.Current != null) { if (GameProject.Project.Current.AvailableScripts.Contains(c.Name)) { desc.Script.ScriptCreator = GetScriptCreatorDll(c.Name); } else { Utils.Logger.Log(Utils.MessageTypes.Error, $"Unable to find script with name {c.Name}, " + $"game entity will be created without script component"); } } } return(CreateGameEntity(desc)); }
public static void RemoveGameEntity(Components.GameEntity entity) { RemoveGameEntity(entity.EntityId); }