Пример #1
0
        public override bool Execute(string[] args)
        {
            int radius = -1;
            List <Identifiable.Id> toKill = new List <Identifiable.Id>();

            foreach (var v in args ?? new string[0])
            {
                if (uint.TryParse(v, out uint rad))
                {
                    radius = (int)rad;
                    continue;
                }
                else
                {
                    try
                    {
                        toKill.Add((Identifiable.Id)Enum.Parse(typeof(Identifiable.Id), v, true));
                    }
                    catch
                    {
                    }
                }
            }


            List <GameObject> toDestroy = new List <GameObject>();

            foreach (var v in SceneContext.Instance.GameModel.AllActors().Where(x => radius == -1 || Vector3.Distance(x.Value?.transform?.position ?? SceneContext.Instance.PlayerState.model.position, SceneContext.Instance.PlayerState.model.position) < radius))
            {
                if (toKill.Count == 0 || toKill.Contains(v.Value.ident))
                {
                    toDestroy.Add(v.Value?.transform?.gameObject);
                }
            }
            int deletedCount = 0;

            foreach (var v in toDestroy)
            {
                if (v)
                {
                    deletedCount++;
                    DeathHandler.Kill(v, DeathHandler.Source.UNDEFINED, SceneContext.Instance.Player, "KillAllCommand.Execute");
                }
            }
            Console.LogSuccess($"Destroyed {deletedCount} actors!");
            return(true);
        }
Пример #2
0
        public override bool Execute(string[] args)
        {
            if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out var hit))
            {
                var gameobject = hit.collider.gameObject;
                if (gameobject.GetComponent <Identifiable>())
                {
                    DeathHandler.Kill(gameobject, DeathHandler.Source.UNDEFINED, SceneContext.Instance.Player, "RemoveCommand.Execute");
                }
                else if (gameobject.GetComponent <Gadget>())
                {
                    gameobject.GetComponent <Gadget>().DestroyGadget();
                }
                else if (gameobject.GetComponentInParent <LandPlot>())
                {
                    gameobject.GetComponentInParent <LandPlotLocation>().Replace(gameobject.GetComponentInParent <LandPlot>(), GameContext.Instance.LookupDirector.GetPlotPrefab(LandPlot.Id.EMPTY));
                }
            }
failure:
            Console.LogError("Not looking at a valid object!");
            return(false);
        }