Пример #1
0
 public static void Load()
 {
     sheet  = Datasheet.Load <SpawnPreset>("/obj.txt");
     lookup = new Dictionary <long, SpawnPreset>();
     foreach (SpawnPreset obj in sheet)
     {
         obj.mode = StaticObjectMode.GetByToken(obj.modeToken, StaticObjectMode.Neutral);
         lookup.Add(Key(obj.act - 1, obj.type, obj.id), obj);
     }
 }
Пример #2
0
        void Execute(string input)
        {
            if (input == "")
            {
                return;
            }

            if (history.Count == 0 || history[history.Count - 1] != input)
            {
                history.Add(input);
            }

            string[] parts = input.Split(' ');
            if (parts.Length >= 2 && parts[0] == "/spawn")
            {
                var pos = Iso.MapToWorld(IsoInput.mouseTile);
                if (parts[1] == "flippy")
                {
                    string flippyFile = @"data\global\items\flp" + parts[2] + ".dc6";
                    Loot.Create(pos, flippyFile, flippyFile);
                    return;
                }

                if (parts[1] == "item")
                {
                    string subname    = parts[2].ToLower();
                    var    uniqueItem = UniqueItem.sheet.Find(s => s.nameStr.ToLower().Contains(subname));
                    if (uniqueItem != null)
                    {
                        ItemDrop.Drop(uniqueItem, pos);
                    }
                    else
                    {
                        string code = parts[2];
                        ItemDrop.Drop(code, pos, 100);
                    }

                    return;
                }

                if (parts[1] == "itemset")
                {
                    string subname = parts[2].ToLower();
                    var    set     = ItemSet.sheet.Find(s => s.id.ToLower().Contains(subname));
                    if (set != null)
                    {
                        foreach (var setItem in set.items)
                        {
                            ItemDrop.Drop(setItem, pos);
                        }
                    }
                    return;
                }

                var id = parts[1];

                var objectInfo = ObjectInfo.Find(id);
                if (objectInfo != null)
                {
                    var obj = WorldBuilder.SpawnObject(objectInfo, pos, fit: true);
                    if (obj != null && parts.Length > 2)
                    {
                        var mode = StaticObjectMode.GetByToken(parts[2], StaticObjectMode.Neutral);
                        obj.SetMode(mode);
                    }
                }
                else
                {
                    int monsterCount = parts.Length > 2 ? int.Parse(parts[2]) : 1;
                    for (int i = 0; i < monsterCount; ++i)
                    {
                        WorldBuilder.SpawnMonster(id, pos);
                    }
                }
            }
            else if (parts.Length == 2 && parts[0] == "/act")
            {
                if (int.TryParse(parts[1], out int actNumber))
                {
                    WorldBuilder.LoadAct(actNumber);
                }
            }
            else if (parts.Length == 2 && parts[0] == "/addstate")
            {
                string stateCode = parts[1];
                var    stateInfo = StateInfo.FindByCode(stateCode);
                if (stateInfo != null)
                {
                    var player = WorldState.instance.Player.gameObject;
                    Overlay.Create(player, stateInfo.castoverlay, loop: false);
                    Overlay.Create(player, stateInfo.overlay1, loop: true);
                    Overlay.Create(player, stateInfo.overlay2, loop: true);
                    Overlay.Create(player, stateInfo.overlay3, loop: true);
                    Overlay.Create(player, stateInfo.overlay4, loop: true);
                }
            }
            else
            {
                Debug.LogWarning(input);
            }
        }