public async Task <bool> SaveAsync(IProgressEx Progress) { if ((await ComponentSet.SaveAsync(Progress)) == false) { return(false); } if ((await ViewSet.SaveAsync(Progress)) == false) { return(false); } try { XDocument xDoc = new XDocument(); xDoc.Add(this.Xml); xDoc.Save(_projectFilePath); _hasChanges = false; } catch (Exception ex) { MainLogger.Log(ex); return(false); } return(true); }
public MudEntity(int id, string name = null) { Traits = new TraitSet(id); Components = new ComponentSet(id); Name = name ?? "-none-"; Id = id; }
private ComponentSet AddUdonComponent(UdonSharpProgramAsset program, List <string> titleArray) { string title = ConfirmTitle(program.GetClass().Name.Replace("T23_", ""), titleArray); Type t23Type = program.GetClass(); Component newComponent = gameObject.AddComponent(t23Type); FieldInfo groupField = t23Type.GetField("groupID"); if (groupField != null) { groupField.SetValue(newComponent, groupID); } FieldInfo titleField = t23Type.GetField("title"); if (titleField != null) { titleField.SetValue(newComponent, title); } UdonSharpBehaviour[] usharpArray = { (UdonSharpBehaviour)newComponent }; UdonBehaviour[] udon = UdonSharpEditorUtility.ConvertToUdonBehaviours(usharpArray); ComponentSet res = new ComponentSet(); res.title = title; res.component = udon[0]; return(res); }
public InternalScript(string MapFileLocation) { //On Initialisation, we want to be able to take in the document object, setting the _doc variable to this. Application app = new Application(); Document doc = app.NewDocument(MapFileLocation, false); _doc = doc; comps = (ComponentSet)_doc.ComponentSet; }
public void RemoveBroadcast() { if (broadcastSet.component) { DestroyImmediate(broadcastSet.component); } broadcastSet = new ComponentSet(); }
/// <summary> /// Don't instantiate this manually. Call <see cref="EntityManager"/>'s NewEntity() function /// </summary> /// <param name="id">Id given to the entity by the entity manager</param> /// <param name="entityManager"></param> internal Entity(int id, EntityManager entityManager, Transform transform) { Id = id; EntityManager = entityManager; Transform = transform; ComponentSet = new ComponentSet(); Children = new List <IEntity>(); }
public void AddAction(UdonSharpProgramAsset program) { ComponentSet set = AddUdonComponent(program, actionTitles); actionSet.Add(set); actionTitles.Add(set.title); OrderComponents(); shouldMoveComponents = true; }
public void AddTrigger(UdonSharpProgramAsset program) { ComponentSet set = AddUdonComponent(program, triggerTitles); triggerSet.Add(set); triggerTitles.Add(set.title); OrderComponents(); shouldMoveComponents = true; }
public AiGEntity(int id, string name = null, int?parent = null) { Name = name ?? "-none-"; Id = id; Traits = new TraitSet(id); Components = new ComponentSet(id); Children = new List <int>(); Parent = parent; }
public void ComponentSetsAreComparable() { var object1 = new ComponentSet(typeof(Transform)); var object2 = new ComponentSet(typeof(Transform)); var object3 = new ComponentSet(typeof(Transform), typeof(Renderable)); Assert.AreEqual(object1, object2); Assert.AreNotEqual(object1, object3); }
public void DictionaryLookupIsSuccessful() { var dictionary = new Dictionary <ComponentSet, int>(); dictionary.Add(new ComponentSet(typeof(Transform)), 123); var lookup = new ComponentSet(typeof(Transform)); Assert.That(dictionary[lookup], Is.EqualTo(123)); }
public void RemoveComponent <T>(IEntity entity) where T : IComponent { var type = typeof(T); var newComponentSet = new ComponentSet(entity.ComponentSet.ComponentTypes.Where(x => x != type).ToArray()); _entitiesWithComponent[type].Remove(entity); _entityComponents[entity].Remove(type); RemoveFromSystems(entity); ChangeEntityComponentSet(entity, newComponentSet); }
public void Load(string FilePath, IProgressEx Progress = null) { _hasChanges = false; _projectFilePath = FilePath; ProjectBasePath = Path.GetDirectoryName(_projectFilePath); MainLogger.Log(String.Format("Loading Project File '{0}'...", Path.GetFileName(_projectFilePath)), 0, LogMessageType.Information, LogReceiver.Console | LogReceiver.StatusBar); XDocument xDoc = XDocument.Load(FilePath); // Deserializing the project from XML document this.Xml = xDoc.Element("Project"); // Base directory where the components are stored ComponentSet.BaseDir = Path.Combine(ApplicationBasePath, _COMPONENTS_DIR); // Optional project directory where the components are stored ComponentSet.ProjectDir = Path.Combine(ProjectBasePath, _COMPONENTS_DIR); ComponentSet.VerboseLoad = IsVerboseLoad(); // Loading components ComponentSet.Load(Progress); CheckComponents(); // If views are defined, load them if (ViewSet != null) { ViewSet.VerboseLoad = ComponentSet.VerboseLoad; ViewSet.Components = ComponentSet; ViewSet.BaseDir = Path.Combine(ApplicationBasePath, _VIEWS_DIR); ViewSet.ProjectBaseDir = Path.Combine(ProjectBasePath, _VIEWS_DIR); ViewSet.Load(Progress); } if (ComponentSet.HasExceptions || ViewSet.HasExceptions) { MainLogger.Log(string.Format("Project '{0}' has loaded with problems!", Properties["Title"]), 0, LogMessageType.Exclamation, LogReceiver.Console | LogReceiver.StatusBar | LogReceiver.MessageBox); } else { MainLogger.Log(string.Format("Project '{0}' loaded successfully!", Properties["Title"]), 0, LogMessageType.Success, LogReceiver.Console | LogReceiver.StatusBar); } _target = (ITarget)ComponentSet["Target"].Plugin; _loaded = true; }
public void TestTrigger() { if (triggerTitles.Count > 0) { ComponentSet set = GetComponentSet(triggerSet, triggerTitles[0]); UdonSharpBehaviour proxy = UdonSharpEditorUtility.FindProxyBehaviour(set.component); UdonSharpEditorUtility.CopyProxyToUdon(proxy, ProxySerializationPolicy.All); set.component.SendCustomEvent("Trigger"); UdonSharpEditorUtility.CopyUdonToProxy(proxy, ProxySerializationPolicy.All); } }
public void ChangeBroadcast() { if (!broadcastTitles.Contains(broadcastSet.title) || broadcastSet.component == null) { if (broadcastSet.component) { DestroyImmediate(broadcastSet.component); } broadcastSet = new ComponentSet(); } }
private void ChangeEntityComponentSet(IEntity entity, ComponentSet newComponentSet) { _entitiesWithComponentSet[entity.ComponentSet].Remove(entity); if (!_entitiesWithComponentSet.ContainsKey(newComponentSet)) { _entitiesWithComponentSet.TryAdd(newComponentSet, new List <IEntity>()); } _entitiesWithComponentSet[newComponentSet].Add(entity); entity.ComponentSet = newComponentSet; }
public void JoinAction(UdonSharpBehaviour baseComponent) { ComponentSet set = JoinUdonComponent(baseComponent, actionTitles); actionSet.Add(set); actionTitles.Add(set.title); OrderComponents(); shouldMoveComponents = true; UdonBehaviour udon = UdonSharpEditorUtility.GetBackingUdonBehaviour(baseComponent); DestroyImmediate(udon); }
public void Unload() { if (ComponentSet != null) { ComponentSet.Unload(null); } if (ViewSet != null) { ViewSet.Unload(null); } _loaded = false; }
public List <ITerribleSystem> SystemsWhichSatisfy(ComponentSet componentSet) { var systems = new List <ITerribleSystem>(); foreach (var kv in _systemDependencies) { var systemComponentSet = kv.Key.RequiredTypes.ComponentTypes; if (!systemComponentSet.Except(componentSet.ComponentTypes).Any()) { systems.AddRange(kv.Value); } } return(systems); }
public void JoinBroadcast(UdonSharpBehaviour baseComponent) { if (broadcastTitles.Count > 0) { broadcastTitles.Clear(); ChangeBroadcast(); } ComponentSet set = JoinUdonComponent(baseComponent, broadcastTitles); broadcastSet = set; broadcastTitles.Add(set.title); OrderComponents(); shouldMoveComponents = true; UdonBehaviour udon = UdonSharpEditorUtility.GetBackingUdonBehaviour(baseComponent); DestroyImmediate(udon); }
public void SetBroadcast(UdonSharpProgramAsset program) { if (broadcastSet.component && broadcastSet.component.programSource == program) { return; } if (broadcastTitles.Count > 0) { broadcastTitles.Clear(); ChangeBroadcast(); } ComponentSet set = AddUdonComponent(program, broadcastTitles); broadcastSet = set; broadcastTitles.Add(set.title); OrderComponents(); shouldMoveComponents = true; }
private ComponentSet JoinUdonComponent(UdonSharpBehaviour baseComponent, List <string> titleArray) { string title = ConfirmTitle(baseComponent.GetType().Name.Replace("T23_", ""), titleArray); Type t23Type = baseComponent.GetType(); Component newComponent = gameObject.AddComponent(t23Type); FieldInfo[] fields = t23Type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); foreach (FieldInfo field in fields) { field.SetValue(newComponent, field.GetValue(baseComponent)); } FieldInfo groupField = t23Type.GetField("groupID"); if (groupField != null) { groupField.SetValue(newComponent, groupID); } FieldInfo titleField = t23Type.GetField("title"); if (titleField != null) { titleField.SetValue(newComponent, title); } UdonSharpBehaviour[] usharpArray = { (UdonSharpBehaviour)newComponent }; UdonBehaviour[] udon = UdonSharpEditorUtility.ConvertToUdonBehaviours(usharpArray); ComponentSet res = new ComponentSet(); res.title = title; res.component = udon[0]; return(res); }
public bool MoveComponents() { int correctidx = GetComponentIndex(components, this); bool success = true; if (broadcastSet.component) { if (!AlignComponent(broadcastSet.component, ref correctidx)) { success = false; } } foreach (string title in triggerTitles) { ComponentSet set = GetComponentSet(triggerSet, title); if (set.component) { if (!AlignComponent(set.component, ref correctidx)) { success = false; } } } foreach (string title in actionTitles) { ComponentSet set = GetComponentSet(actionSet, title); if (set.component) { if (!AlignComponent(set.component, ref correctidx)) { success = false; } } } return(success); }
public DependsOnComponents(params Type[] types) { RequiredTypes = new ComponentSet(types); }
public void OrderComponents() { int correctidx = GetComponentIndex(components, this); List <Component> orderList = new List <Component>(); if (broadcastSet.component) { orderList.Add(broadcastSet.component); } else { broadcastTitles.Remove(broadcastSet.title); broadcastSet = new ComponentSet(); } List <ComponentSet> deleteSet = new List <ComponentSet>(); foreach (string title in triggerTitles) { ComponentSet set = GetComponentSet(triggerSet, title); if (set.component) { orderList.Add(set.component); } else { deleteSet.Add(set); } } foreach (ComponentSet set in deleteSet) { triggerTitles.Remove(set.title); triggerSet.Remove(set); } deleteSet = new List <ComponentSet>(); foreach (string title in actionTitles) { ComponentSet set = GetComponentSet(actionSet, title); if (set.component) { orderList.Add(set.component); } else { deleteSet.Add(set); } } foreach (ComponentSet set in deleteSet) { actionTitles.Remove(set.title); actionSet.Remove(set); } foreach (var component in orderList) { UdonBehaviour udon = (UdonBehaviour)component; udon.interactText = interactText; udon.proximity = proximity; udon.SyncMethod = reliable ? VRC.SDKBase.Networking.SyncType.Manual : VRC.SDKBase.Networking.SyncType.Continuous; } }