Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    internal void Set(int id)
    {
        SandboxObjectData sandboxObjectData = ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, id);

        _components.objectNameLabel.text = sandboxObjectData.name;
        base.valueReference.set(id);
    }
Esempio n. 3
0
    internal override ModuleData Clone()
    {
        SandboxObjectData sandboxObjectData = new SandboxObjectData(this);

        sandboxObjectData.id = GameHead.instance.universeData.GenerateUniqueId();
        return(sandboxObjectData);
    }
Esempio n. 4
0
 internal override void PopulateData(ModuleData moduleData)
 {
     _data = (SandboxObjectData)moduleData;
     SpawnModules(_data.modules);
     ApplyData();
     PostProcessModules();
 }
Esempio n. 5
0
    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;
    }
Esempio n. 6
0
    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);
    }
Esempio n. 7
0
    internal override void PopulateData(ModuleData moduleData)
    {
        _data = (SandboxObjectReferenceData)moduleData;
        SandboxObjectData sandboxObjectData = ModuleHead.GetSandboxObjectDataById(GameHead.instance.universeData, _data.id);

        SpawnNestedModules(sandboxObjectData);
        ApplyData();
    }
Esempio n. 8
0
 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);
         }
     }
 }
Esempio n. 9
0
    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);
    }
Esempio n. 10
0
    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);
    }
Esempio n. 11
0
    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();
    }
Esempio n. 12
0
    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());
        }
    }
Esempio n. 13
0
 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);
 }
Esempio n. 14
0
    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);
    }
Esempio n. 15
0
 internal void Populate(SandboxObjectData sandboxObjectData, Action <int> callback)
 {
     _data.callback             = callback;
     _components.nameLabel.text = sandboxObjectData.name;
     _data.id = sandboxObjectData.id;
 }
Esempio n. 16
0
 internal SandboxObjectSpawnData(SandboxObjectData sandboxObjectData)
 {
     id   = sandboxObjectData.id;
     name = sandboxObjectData.name;
 }
Esempio n. 17
0
 public SandboxObjectReferenceData(SandboxObjectData sandboxObjectData)
 {
     id   = sandboxObjectData.id;
     name = sandboxObjectData.name;
 }