public bool AddEntity(ButtEntity ent)
 {
     if (!this.EntityExistsAtLocation(ent.pos))
     {
         levelToCreate.Add(ent);
         return(true);
     }
     return(false);
 }
    void Start()
    {
        ButtEntity item = FrEdNodeScript.instance.GetBehaviourItem(aniId);

        RoughFFrames_to_Animation(item.frames);

        switch (mode)
        {
        case Mode.BasicLoop:
            PlayAnimation(0);
            break;
        }
    }
 private void HandlePaint(Modifiers keyModifiers)
 {
     if (!this.CursorIsOverUIElement() && Input.GetMouseButton(LEFT_CLICK) && !this.node.EntityExistsAtLocation(this.currentMouseGridPos))
     {
         ButtEntity block = new ButtEntity();
         block.type = FrEdLibrary.Type.Block;
         block.Initialize();
         block.pos = this.currentMouseGridPos;
         if (this.node.AddEntity(block))
         {
             this.node.CreateItem(block);
         }
     }
 }
    private Transform GetParent(ButtEntity item)
    {
        Transform parent = null;

        switch (item.type)
        {
        case FrEdLibrary.Type.Block:
            parent = this.blockParent;
            break;

        default:
            parent = this.entityParent;
            break;
        }
        return(parent);
    }
    public GameObject CreateItem(ButtEntity item)
    {
        GameObject go = null;

        FrEdLibrary.uIds++;
        item.uId = FrEdLibrary.uIds;

        if (item.type == FrEdLibrary.Type.SetSky)
        {
            this.sky.ConfigureSky(item.color1, item.color2, item.skyBands);
            return(null);
        }

        GameObject prefab = FrEdLibrary.instance.GetPrefab(item.type);

        if (prefab != null)
        {
            go = Instantiate <GameObject>(prefab, new Vector3(item.pos.x, item.pos.y, item.zPos), prefab.transform.rotation, this.GetParent(item));
            item.ApplyToGameObject(go);
            item.sceneReference = go;
        }
        return(go);
    }
    private List <ButtEntity> RemoveFromSelection(Vector3 start, Vector3 end)
    {
        List <ButtEntity> list = new List <ButtEntity>();
        Rect box = Utils.RectFromPoints(start, end);

        for (int i = 0; i < this.selectedItems.Count; ++i)
        {
            ButtEntity ent = this.selectedItems[i];
            if (box.Contains(ent.pos))
            {
                list.Add(ent);
                this.selectedItems.RemoveAt(i--);
                if (ent.sceneReference != null)
                {
                    Transform t   = ent.sceneReference.transform;
                    Vector3   rot = t.localEulerAngles - SELECTION_ROT_OFFSET;
                    t.localEulerAngles = rot;
                    Vector3 pos = t.position + SELECTION_POS_OFFSET;
                    t.position = pos;
                }
            }
        }
        return(list);
    }
    private void HandleEntity(Modifiers keyModifiers)
    {
        if (!this.CursorIsOverUIElement() && Input.GetMouseButtonDown(LEFT_CLICK) && !this.node.EntityExistsAtLocation(this.currentMouseGridPos))
        {
            FrEdLibrary.Type type = this.SelectedEntity.type;
            switch (type)
            {
            default:
                ButtEntity ent = new ButtEntity();
                ent.type = type;
                ent.Initialize();
                ent.pos = this.currentMouseGridPos;
                if (this.node.AddEntity(ent))
                {
                    this.node.CreateItem(ent);
                }
                break;

            case FrEdLibrary.Type.PlayerSpawn:

                break;
            }
        }
    }
    List <ButtEntity> RawToItemList(string raw)
    {
        List <ButtEntity> itemList = new List <ButtEntity>();

        customPrefabs    = new List <ButtEntity>();
        customBehaviours = new List <ButtEntity>();

        string[] wholeItems = raw.Split(new char[] { ';' }, System.StringSplitOptions.RemoveEmptyEntries);

        for (int i = 0; i < wholeItems.Length; i++)
        {
            ButtEntity item = new ButtEntity();
            bool       thisItemIsAPrefab    = false;
            bool       thisItemIsABehaviour = false;

            if (wholeItems[i].Length > 0)
            {
                string[] stats = wholeItems[i].Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                for (int a = 0; a < stats.Length; a++)
                {
                    if (stats[a].Length > 0)
                    {
                        string[] parts = stats[a].Split(new char[] { ':' }, System.StringSplitOptions.RemoveEmptyEntries);

                        int typeResult = 0;
                        if (parts.Length == 2)
                        {
                            typeResult = item.SetProperty(parts[0], parts[1]);
                        }
                        switch (typeResult)
                        {
                        default:
                        case 0:
                            break;

                        case 1:
                            thisItemIsAPrefab = true;
                            break;

                        case 2:
                            thisItemIsABehaviour = true;
                            break;
                        }
                    }
                }
            }
            item.Initialize();

            if (thisItemIsAPrefab)
            {
                customPrefabs.Add(item);
            }
            else if (thisItemIsABehaviour)
            {
                customBehaviours.Add(item);
            }
            else
            {
                itemList.Add(item);
            }
        }
        return(itemList);
    }
 public void DeleteEntity(ButtEntity ent)
 {
     levelToCreate.Remove(ent);
     GameObject.Destroy(ent.sceneReference);
 }