private Module SpawnModule(ModuleData moduleData) { if (GameHead.instance.isPreviewOrRuntime) { if (moduleData is SandboxObjectReferenceData || moduleData is SandboxObjectSpawnData) { SandboxObjectData sandboxObjectData = new SandboxObjectData(ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, moduleData.id)); sandboxObjectData.position = moduleData.position; sandboxObjectData.rotation = moduleData.rotation; sandboxObjectData.scale = moduleData.scale; moduleData = sandboxObjectData; } } Module prefab = ModuleHead.instance.GetModulePrefab(moduleData.GetType()); GameObject gameObject = Instantiate(prefab.gameObject, base.transform); gameObject.name = moduleData.name; Module instance = gameObject.GetComponent <Module>(); instance.parent = this; _idModuleMap.Add(moduleData.id, instance); instance.PopulateData(moduleData); return(instance); }
internal void Set(int id) { SandboxObjectData sandboxObjectData = ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, id); _components.objectNameLabel.text = sandboxObjectData.name; base.valueReference.set(id); }
internal override ModuleData Clone() { SandboxObjectData sandboxObjectData = new SandboxObjectData(this); sandboxObjectData.id = GameHead.instance.universeData.GenerateUniqueId(); return(sandboxObjectData); }
internal override void PopulateData(ModuleData moduleData) { _data = (SandboxObjectData)moduleData; SpawnModules(_data.modules); ApplyData(); PostProcessModules(); }
internal void Populate(SandboxObjectData sandboxObjectData) { _data.sandboxObjectData = sandboxObjectData; InspectionData inspectionData = null; if (EditorHead.instance.isMap) { inspectionData = ModuleHead.instance.GetInspectionDataOfType(typeof(SandboxObjectSpawn)); } else { inspectionData = ModuleHead.instance.GetInspectionDataOfType(typeof(SandboxObjectReference)); } ColorBlock colorBlock = new ColorBlock(); colorBlock = _components.colorImage.colors; colorBlock.normalColor = inspectionData.color; _components.colorImage.colors = colorBlock; _components.iconImage.sprite = inspectionData.icon; _components.nameLabel.text = sandboxObjectData.name; }
private void CreateObjectButton(SandboxObjectData sandboxObjectData) { GameObject gameObject = Instantiate(_prefabs.objectButton.gameObject, _components.objectContainer, false); WUIObjectMenuButton wUIObjectMenuButton = gameObject.GetComponent <WUIObjectMenuButton>(); _components.buttons.Add(wUIObjectMenuButton); wUIObjectMenuButton.Populate(sandboxObjectData, Set); }
internal override void PopulateData(ModuleData moduleData) { _data = (SandboxObjectReferenceData)moduleData; SandboxObjectData sandboxObjectData = ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, _data.id); SpawnNestedModules(sandboxObjectData); ApplyData(); }
private void SpawnNestedModules(SandboxObjectData sandboxObjectData) { foreach (ModuleData moduleData in sandboxObjectData.modules) { bool isPublicLink = moduleData is ModuleLogicLinkData && ((ModuleLogicLinkData)moduleData).isPublic; if (moduleData is ModuleArtData || moduleData is SandboxObjectReferenceData || isPublicLink) { SpawnNestedModule(moduleData); } } }
internal SandboxObjectData NewSandboxObject(int sandboxObjectID, int publicLinkID) { SandboxObjectData sandboxObjectData = new SandboxObjectData { id = sandboxObjectID, name = $"SANDBOX OBJECT : {sandboxObjectID}", position = Vector3.zero, rotation = Vector3.zero, scale = Vector3.one, }; sandboxObjectData.modules.Add(new ModuleLogicLinkData { id = publicLinkID, name = $"PUBLIC LINK : {sandboxObjectID}", isPublic = true, position = Vector3.up * 2f, scale = Vector3.one * 0.25f }); return(sandboxObjectData); }
internal override void Bind(SandboxValue sandboxValue) { base.valueReference = sandboxValue; int id = ((int)sandboxValue.get()); if (id != -1) { SandboxObjectData sandboxObjectData = ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, id); _components.objectNameLabel.text = sandboxObjectData.name; } else { _components.objectNameLabel.text = "EMPTY"; } wUITipable.Populate(sandboxValue.id, sandboxValue.description); }
public void UE_CreateNew() { if (_data.editorType == EditorType.Object) { SandboxObjectData sandboxObjectData = EditorHead.instance.NewSandboxObject(_data.universeData.GenerateUniqueId(), _data.universeData.GenerateUniqueId()); sandboxObjectData.category = _data.activeCategory; _data.universeData.objects.Add(sandboxObjectData); } else { SandboxData sandboxData = EditorHead.instance.NewSandbox(_data.universeData.GenerateUniqueId()); _data.universeData.maps.Add(sandboxData); } UserHead.SaveAllUsersData(); Refresh(); }
public SandboxObjectData(SandboxObjectData sandboxObjectData) { id = sandboxObjectData.id; parentId = sandboxObjectData.parentId; name = sandboxObjectData.name; category = sandboxObjectData.category; position = sandboxObjectData.position; rotation = sandboxObjectData.rotation; scale = sandboxObjectData.scale; tags = sandboxObjectData.tags; modules = new List <ModuleData>(); foreach (ModuleData moduleData in sandboxObjectData.modules) { modules.Add(moduleData.Clone()); } }
private bool HasChildRecursive(SandboxObjectData sandboxObjectData, int id) { for (int i = 0; i < sandboxObjectData.modules.Count; i++) { if (!(sandboxObjectData.modules[i] is SandboxObjectReferenceData)) { continue; } SandboxObjectReferenceData childSandboxObjectData = (SandboxObjectReferenceData)sandboxObjectData.modules[i]; int childId = childSandboxObjectData.id; if (childId == id) { return(true); } bool overflow = HasChildRecursive(ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, childId), id); if (overflow) { return(true); } } return(false); }
internal List <SandboxObjectData> GetNestableObjects() { List <SandboxObjectData> nonOverflowingSandboxObjects = new List <SandboxObjectData>(); for (int i = 0; i < GameHead.instance.universeData.objects.Count; i++) { SandboxObjectData sandboxObjectData = (SandboxObjectData)GameHead.instance.universeData.objects[i]; if (sandboxObjectData.id == editableData.id) { continue; } if (sandboxObjectData.modules.Count > 0) { bool overflowable = HasChildRecursive(sandboxObjectData, editableData.id); if (overflowable) { continue; } } nonOverflowingSandboxObjects.Add(sandboxObjectData); } return(nonOverflowingSandboxObjects); }
internal void Populate(SandboxObjectData sandboxObjectData, Action <int> callback) { _data.callback = callback; _components.nameLabel.text = sandboxObjectData.name; _data.id = sandboxObjectData.id; }
internal SandboxObjectSpawnData(SandboxObjectData sandboxObjectData) { id = sandboxObjectData.id; name = sandboxObjectData.name; }
public SandboxObjectReferenceData(SandboxObjectData sandboxObjectData) { id = sandboxObjectData.id; name = sandboxObjectData.name; }