private void AddComponentToMapper <T>(int name, ref T target, out int autoID) where T : IShipDockComponent, new() { autoID = mMapper.Add(target, out int statu); if (statu == 0) { mNameAutoIDMapper[name] = autoID; target.SetComponentID(autoID); target.Init(this); RelateComponentsReFiller?.Invoke(name, target, this); "log: Add ECS component {0}".Log(name.ToString()); } else { autoID = -1; } }
public int Create <T>(int name, bool isUpdateByScene = false, params int[] willRelateComponents) where T : IShipDockComponent, new() { T target = new T { RelateComponents = willRelateComponents }; target.SetSceneUpdate(isUpdateByScene); target.OnFinalUpdateForTime = OnFinalUpdateForTime; target.OnFinalUpdateForEntitas = OnFinalUpdateForEntitas; target.OnFinalUpdateForExecute = OnFinalUpdateForExecute; int aid = mMapper.Add(target, out int statu); if (isUpdateByScene) { mUpdateByScene.Add(target); } else { mUpdateByTicks.Add(target); } if (statu == 0) { mIDMapper[name] = aid; target.SetComponentID(aid); target.FillRelateComponents(this); target.Init(); RelateComponentsReFiller?.Invoke(name, target, this); } else { aid = -1; } return(aid); }