public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string to_op   = args.GetString("verb");
            string objname = args.GetString("target");

            if (objname == "")
            {
                return(Failure("$bot don't know what object to use."));
            }
            if (to_op == "")
            {
                SimObject objToUse;
                if (WorldSystem.tryGetPrim(objname, out objToUse))
                {
                    if ((BotNeeds)TheSimAvatar["CurrentNeeds"] == null)
                    {
                        TheSimAvatar["CurrentNeeds"] = new BotNeeds(90.0f);
                    }
                    SimTypeUsage usage = objToUse.Affordances.GetBestUse((BotNeeds)TheSimAvatar["CurrentNeeds"]);
                    if (usage == null)
                    {
                        //usage = new MoveToLocation(TheSimAvatar, objToUse);
                        return(Failure("$bot don't have a use for " + objToUse + " yet."));
                    }
                    TheSimAvatar.Do(usage, objToUse);
                    return(Success("used " + objToUse));
                }
                return(Failure("$bot don't know what to do with " + objname));
            }
            WriteLine("Trying to (" + to_op + ") with (" + objname + ")");
            TheBotClient.UseInventoryItem(to_op, objname);
            return(Success("completed to (" + to_op + ") with (" + objname + ")"));
        }
Exemple #2
0
        public EditorApp(
            ImGuiRenderer imGuiRenderer,
            GameWindow gameWindow,
            IReadOnlyList <IWindow> windows,
            GameClock gameClock,
            WorldSystem worldSystem,
            EditTileMapState editTileMapState,
            IAssetsDatabase assetsDatabase
            )
        {
            _imGuiRenderer  = imGuiRenderer;
            _windows        = windows;
            _gameClock      = gameClock;
            _worldSystem    = worldSystem;
            _editorAppState = editTileMapState;
            _assetsDatabase = assetsDatabase;

            _imGuiRenderer.RebuildFontAtlas();
            var imGuiIo = ImGui.GetIO();

            imGuiIo.ConfigWindowsMoveFromTitleBarOnly = true;
            imGuiIo.ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            gameWindow.AllowUserResizing = true;

            _worldSystem.CreateNewWorld();
        }
Exemple #3
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            UUID primID = UUID.Zero;

            if (args.Length < 1)
            {
                foreach (SimObject O in WorldSystem.TheSimAvatar.GetNearByObjects(10, true))
                {
                    WriteLine("\n {0}", WorldSystem.describePrim(O.Prim, false));
                }
                return(Success("Done."));
            }

            int           argsUsed;
            List <string> missingList = new List <string>();
            var           PS          = WorldSystem.GetPrimitiveFromList(args, out argsUsed, missingList);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + missingList));
            }
            foreach (var target in PS)
            {
                WriteLine("\n {0}", WorldSystem.describePrim(target.Prim, true));
                AddSuccess("Done.");
            }
            return(SuccessOrFailure());
        }
Exemple #4
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
                // "rezitem [avatar5,prev,sim/123/232/23@360] "fairyverse Goodies" [item2] [item3] [...]";
            }

            int         argsUsed   = 0;
            string      lowerMatch = args[0].ToLower();
            SimPosition dest       = null;

            if (!args.ContainsFlag("--prev"))
            {
                dest = WorldSystem.GetVector(args.GetProperty("location"), out argsUsed);
            }
            var man   = Client.BotInventory;
            var found = man.FindAll(args.GetProperty("items"), true,
                                    inventoryName => Failure("No inventory item named " + inventoryName + " found."));

            foreach (InventoryBase ib in man.ItemsOnly(found))
            {
                RezAll(man, ib, dest);
            }
            return(Success("found.Count=" + found.Count));
        }
        private void SelectObjects(bool deSelect, ulong fp, List <uint> selectobjs, bool autoDeselect)
        {
            if (selectobjs.Count == 0)
            {
                return;
            }
            Simulator sim = WorldSystem.GetSimulator(fp);

            while (selectobjs.Count > 25)
            {
                var so = selectobjs.GetRange(0, 40);
                selectobjs.RemoveRange(0, 40);
                if (deSelect)
                {
                    Client.Objects.DeselectObjects(sim, so.ToArray());
                }
                else
                {
                    Client.Objects.SelectObjects(sim, so.ToArray(), autoDeselect);
                }
            }
            if (deSelect)
            {
                Client.Objects.DeselectObjects(sim, selectobjs.ToArray());
            }
            else
            {
                Client.Objects.SelectObjects(sim, selectobjs.ToArray(), autoDeselect);
            }
        }
Exemple #6
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                return(ShowUsage());
            }

            int argsUsed;
            List <SimObject> PS = WorldSystem.GetPrimitives(args, out argsUsed);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.str));
            }

            foreach (var currentPrim in PS)
            {
                AddSuccess(Name + " on " + currentPrim);
                if (!TheSimAvatar.AttachToSelf(currentPrim))
                {
                    Failure("Cannot Attach " + currentPrim);
                }
            }
            return(SuccessOrFailure());
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            List <SimObject> PS;

            if (!args.TryGetValue("targets", out PS) || IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.GetString("targets")));
            }
            {
                int nfound = 0;
                foreach (var prim in PS)
                {
                    Client.Self.SendTeleportLure(prim.ID);
                    AddSuccess(Name + ": " + prim);
                    nfound++;
                }
                if (nfound > 0)
                {
                    return(Success(Name + " found: " + nfound + " object/agent(s)"));
                }
            }
            string user = args.str;
            UUID   id   = WorldSystem.GetUserID(user);

            if (id == UUID.Zero)
            {
                return(Failure("Cannot find " + user));
            }
            Client.Self.SendTeleportLure(id);
            return(Success("teleport Lure sent to " + user));
        }
 public SimAvatarImpl(UUID id, WorldObjects objectSystem, Simulator sim)
     : base(id, objectSystem, sim)
 {
     Affordances.ObjectType.SuperType.Add(SimTypeSystem.GetObjectType("Avatar"));
     _knownTypeUsages = new ListAsSet <SimTypeUsage>();
     WorldSystem.AddAvatar(this, id);
 }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
            }
            if (args.ContainsFlag("--all"))
            {
                List <uint> ids = new List <uint>();
                foreach (SimObject o in TheSimAvatar.Children)
                {
                    Success("Detatching " + o);
                    ids.Add(o.LocalID);
                }
                Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), ids);
                return(Success("detatched all " + ids.Count));
            }

            int argsUsed;

            string[]         keyargs = args.GetProperty("targets");
            List <SimObject> PS      = WorldSystem.GetPrimitives(keyargs, out argsUsed);
            List <uint>      idz     = new List <uint>();

            foreach (var o in PS)
            {
                Success("Detatching " + o);
                idz.Add(o.LocalID);
            }
            Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), idz);
            return(Success("detatched  " + args.str + " " + idz.Count));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            //   base.acceptInput(verb, args);

            BotClient      Client  = TheBotClient;
            string         subject = String.Join(" ", args);
            OutputDelegate wtoList = (f, a) => AppendResults("events", string.Format(f, a));

            if (subject.Length == 0)
            {
                return(Success(DebugInfo(TheSimAvatar, wtoList)));
            }

            float range;
            int   blanks    = 0;
            int   nonblanks = 0;

            if (float.TryParse(subject, out range))
            {
                SimAvatar simAva = WorldSystem.TheSimAvatar;
                if (simAva != null)
                {
                    List <SimObject> objs = ((SimObjectImpl)simAva).GetNearByObjects((double)range, false);
                    if (objs.Count > 0)
                    {
                        foreach (SimObject o in objs)
                        {
                            if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                            {
                                blanks++;
                                if (!(o is SimAvatar))
                                {
                                    continue;
                                }
                            }
                            string s = DebugInfo(o, wtoList);
                            WriteLine(s);
                            nonblanks++;
                        }
                    }
                }
            }
            else
            {
                int argsUsed = 0;
                var PS       = WorldSystem.GetPrimitives(Parser.SplitOff(args, argsUsed), out argsUsed);
                foreach (SimObject o in PS)
                {
                    string s = DebugInfo(o, wtoList);
                    WriteLine(s);
                    if (o.ActionEventQueue == null || o.ActionEventQueue.Count == 0)
                    {
                        blanks++;
                        continue;
                    }
                    nonblanks++;
                }
            }
            return(Success("simEventComplete blanks=" + blanks + " nonblanks=" + nonblanks));
        }
Exemple #11
0
        /// <summary>
        /// Get a list of current friends
        /// </summary>
        /// <param name="args">optional testClient command arguments</param>
        /// <param name="fromAgentID">The <seealso cref="OpenMetaverse.UUID"/>
        /// of the agent making the request</param>
        /// <returns></returns>
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;
            IEnumerable <SimObject> objs = WorldSystem.GetPrimitives(args, out argsUsed);

            if (argsUsed == 0)
            {
                return(Success(FriendsCommand.ListFriends(Client)));
            }
            foreach (SimObject o in objs)
            {
                if (!(o is SimAvatar))
                {
                    Failure("Not avatar " + o);
                    continue;
                }
                WriteLine("Adding friend: " + o);
                UUID oID = o.ID;
                if (UUIDFactory.IsNullOrZero(oID))
                {
                    Failure("cant find " + o + " id ");
                }
                else
                {
                    Client.Friends.OfferFriendship(oID);
                }
            }
            return(Success("Ran " + Name));
        }
Exemple #12
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            // Get the agent's current "patch" position, where each patch of
            // wind data is a 16x16m square
            int         argsUsed;
            SimPosition aPos     = WorldSystem.GetVector(args, out argsUsed);
            Vector3     agentPos = aPos.SimPosition;
            int         xPos     = (int)Utils.Clamp(agentPos.X, 0.0f, 255.0f) / 16;
            int         yPos     = (int)Utils.Clamp(agentPos.Y, 0.0f, 255.0f) / 16;
            Simulator   sim      = SimRegion.GetRegion(aPos.GlobalPosition).TheSimulator;

            if (sim == null)
            {
                return(Failure("Unknown simulator for " + aPos));
            }
            ulong handle = sim.Handle;

            if (sim.WindSpeeds == null)
            {
                return(Failure("Unknown wind speed at sim: " + sim));
            }
            Vector2[] windSpeeds = sim.WindSpeeds;
            Vector2   windSpeed  = windSpeeds[yPos * 16 + xPos];

            return(Success("Wind speed at " + aPos + " is " + windSpeed));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            float distance = 2.0f;

            int         argsUsed;
            SimPosition simObject = WorldSystem.GetVector(args, out argsUsed);

            if (simObject == null)
            {
                return(Failure("Cannot find " + args.str));
            }
            if (!simObject.IsRegionAttached)
            {
                return(Failure("Cannot get SimPosition of " + simObject));
            }

            distance = 0.5f + simObject.GetSizeDistance();
            if (argsUsed < args.Length)
            {
                float d;
                if (float.TryParse(args[argsUsed], out d))
                {
                    distance = d;
                }
            }
            WriteLine("WalkTo {0} {1}", simObject, distance);
            WorldSystem.TheSimAvatar.SimpleMoveTo(simObject.GlobalPosition, distance, 10, false);
            WorldSystem.TheSimAvatar.StopMoving();
            return(Success(WorldSystem.TheSimAvatar.DistanceVectorString(simObject)));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                return(ShowUsage());
            }
            int argsUsed;
            List <SimObject> PS = WorldSystem.GetPrimitives(args, out argsUsed);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.str));
            }
            GridClient client = TheBotClient;

            foreach (var currentPrim in PS)
            {
                AddSuccess(Name + " on " + currentPrim);
                if (TheSimAvatar.TakeObject(currentPrim) == null)
                {
                    Failure("Cannot Take " + currentPrim);
                }
            }
            return(SuccessOrFailure());
        }
Exemple #15
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage()); // " goto sim/x/y/z";
            }
            int         argsUsed;
            SimPosition position = WorldSystem.GetVector(args, out argsUsed);

            if (position == null)
            {
                return(Failure("Teleport - Cannot resolve to a location: " + args.str));
            }
            SimPathStore ps     = position.PathStore;
            ulong        handle = SimRegion.GetRegionHandle(ps);

            TheSimAvatar.StopMoving();
            if (Client.Self.Teleport(handle, position.SimPosition))
            {
                return(Success("Teleported to " + Client.Network.CurrentSim));
            }
            else
            {
                return(Failure("Teleport failed: " + Client.Self.TeleportMessage));
            }
        }
 public void AttemptMoveTo(Vector3 pos)
 {
     AttemptSitMover();
     if (pos.X < 1 || pos.Y < 1 || pos.Z < 10 || pos.X > 254 || pos.Y > 254 || pos.Z > 5000)
     {
         return;
     }
     SetCamera(pos);
     if (Vector3.Distance(Client.Self.SimPosition, pos) < 8)
     {
         BeenTo(Client.Self.SimPosition);
         return;
     }
     Success("Trying to get to " + pos);
     Client.Self.Chat(string.Format("tptp,{0},{1},{2}", pos.X, pos.Y, pos.Z), 4201, ChatType.Normal);
     if (!TheSimAvatar.IsSitting)
     {
         SetCamera(pos);
         if (LureMover)
         {
             Client.Self.InstantMessage(WorldSystem.GetUserID("BinaBot Daxeline"), "/lure " + TheSimAvatar.ID);
             Thread.Sleep(4000);
             // return;
         }
         if (Vector3.Distance(Client.Self.SimPosition, pos) < 8)
         {
             SetCamera(pos);
             return;
         }
         uint globalX, globalY;
         Utils.LongToUInts(RegionHandle, out globalX, out globalY);
         ExpectedGotoV3D =
             new Vector3d(
                 (double)globalX + (double)pos.X,
                 (double)globalY + (double)pos.Y,
                 (double)pos.Z);
         Vector3d at3d = Client.Self.GlobalPosition;
         if (Vector3d.Distance(new Vector3d(ExpectedGotoV3D.X, ExpectedGotoV3D.Y, ExpectedGotoV3D.Z), new Vector3d(at3d.X, at3d.Y, at3d.Z)) < 32)
         {
             SetCamera(pos);
             return;
         }
         Client.Self.AutoPilotCancel();
         Client.Self.Teleport(RegionHandle, pos, pos);
         SetCamera(pos);
         Thread.Sleep(4000);
         at3d = Client.Self.GlobalPosition;
         if (Vector3d.Distance(new Vector3d(ExpectedGotoV3D.X, ExpectedGotoV3D.Y, ExpectedGotoV3D.Z), new Vector3d(at3d.X, at3d.Y, at3d.Z)) < 16)
         {
             SetCamera(pos);
             return;
         }
         Success("AutoPilot to get to " + pos);
         Client.Self.AutoPilot(ExpectedGotoV3D.X, ExpectedGotoV3D.Y, ExpectedGotoV3D.Z);
         SetCamera(pos);
         Thread.Sleep(4000);
         Client.Self.AutoPilotCancel();
     }
 }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            bool writeInfo = !args.IsFFI;
            int  count     = 0;

            if (args.ContainsFlag("--presence"))
            {
                foreach (var A in WorldObjects.SimAccounts)
                {
                    count++;
                    AppendItem("agents", A);
                    if (writeInfo)
                    {
                        WriteLine(A + " local=" + A.IsLocal);
                    }
                }
            }
            else
            {
                int[] count0 = { 0 };
                foreach (Simulator sim in LockInfo.CopyOf(Client.Network.Simulators))
                {
                    if (sim.ObjectsAvatars.Count == 0)
                    {
                        continue;
                    }
                    if (writeInfo)
                    {
                        WriteLine("");
                    }
                    if (writeInfo)
                    {
                        WriteLine("Region: " + sim);
                    }
                    Simulator simulator = sim;
                    sim.ObjectsAvatars.ForEach(
                        delegate(Avatar av)
                    {
                        count0[0]++;
                        SimObject A = WorldSystem.GetSimObject(av, simulator);
                        AppendItem("avatars", A);
                        if (string.IsNullOrEmpty(av.Name))
                        {
                            Client.Objects.SelectObjects(simulator, new uint[] { av.LocalID }, true);
                        }
                        if (writeInfo)
                        {
                            WriteLine(" {0} (Group: {1}, Location: {2}, UUID: {3})",
                                      av.Name, av.GroupName, av.Position, av.ID.ToString());
                        }
                    }
                        );
                }
                count = count0[0];
            }
            SetResult("count", count);
            return(SuccessOrFailure());
        }
Exemple #18
0
 public DebugScreen(SpriteBatch spriteBatch, WorldSystem worldSystem, WorldTime worldTime, Camera2D camera)
 {
     SpriteBatch = spriteBatch;
     FPSRate     = new RateCounter();
     UPSRate     = new RateCounter();
     WorldSystem = worldSystem;
     WorldTime   = worldTime;
     Camera      = camera;
 }
Exemple #19
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int         argsUsed;
            SimPosition simObject = WorldSystem.GetVector(args.GetProperty("position"), out argsUsed);

            WriteLine("turnto {0}", simObject);
            WorldSystem.TheSimAvatar.TurnToward(simObject);
            return(Success(WorldSystem.TheSimAvatar.DistanceVectorString(simObject)));
        }
Exemple #20
0
 public Engine(IEntityManager entityManager, WorldSystem worldSystem, MovementSystem movementSystem,
               DrawingSystem drawingSystem, VisionSystem visionSystem, TimeTrackingSystem timeTrackingSystem)
 {
     this.entityManager      = entityManager;
     this.worldSystem        = worldSystem;
     this.movementSystem     = movementSystem;
     this.drawingSystem      = drawingSystem;
     this.visionSystem       = visionSystem;
     this.timeTrackingSystem = timeTrackingSystem;
 }
 public override CmdResult ExecuteRequest(CmdRequest args)
 {
     {
         foreach (Simulator sim in LockInfo.CopyOf(Client.Network.Simulators))
         {
             WorldSystem.CatchUp(sim);
         }
     }
     return(Success("Ran " + Name));
 }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string str;

            if (args.TryGetValue("commandMask", out str))
            {
                SortedList <string, CommandInfo> all = null;
                if (TheBotClient != null)
                {
                    all = TheBotClient.AllCommands();
                }
                else
                {
                    all = ClientManager.SingleInstance.AllCommands();
                }
                foreach (var cmdinfo in all)
                {
                    if (cmdinfo.Value.Matches(str))
                    {
                        WriteLine(cmdinfo.Value.ToPrologString());
                    }
                }
            }
            WriteLine("GroupNames:");
            foreach (var name  in  WorldSystem.GroupNames)
            {
                WriteLine("$" + name);
            }
            WriteLine("Filters:");
            Type typesearch = typeof(SimObjectImpl);
            IEnumerable <FilterMember> filters = WorldSystem.GetFilters(typesearch);

            foreach (FilterMember fmemb in filters)
            {
                if (!fmemb.IsCollectionType)
                {
                    continue;
                }
                WriteLine(typeString(fmemb.ReturnType) + " < = "
                          + fmemb.ReflectionMember.Name + (fmemb.IsOf ? "Of" : "")
                          + typeString(fmemb.CastArgTo));
            }
            foreach (FilterMember fmemb in filters)
            {
                if (fmemb.IsCollectionType)
                {
                    continue;
                }
                WriteLine("[!]"
                          + fmemb.ReflectionMember.Name + (fmemb.IsOf ? "Of" : "")
                          + (fmemb.PreCompare ? "<>" : "")
                          + typeString(fmemb.CastArgTo));
            }
            return(Success("Help complete"));
        }
Exemple #23
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                return(ShowUsage());
            }
            SimObject o;

            if (!args.TryGetValue("target", out o))
            {
                return(Failure(string.Format("Cant find {0}", args.str)));
            }
            bool      isObject    = !(o is SimAvatar);
            UUID      target      = o.ID;
            Primitive currentPrim = o.Prim;

            if (currentPrim == null)
            {
                return(Failure(string.Format("No Prim localId for {0}", args.str)));
            }
            Primitive.ObjectProperties props = o.Properties;
            WorldObjects.EnsureSelected(currentPrim, WorldSystem.GetSimulator(currentPrim));
            if (props == null)
            {
                return(Failure("no props on " + o + " yet try again"));
            }
            GridClient client = TheBotClient;
            string     strA;

            if (!args.TryGetValue("ammount", out strA))
            {
                return(Success(string.Format("saletype {0} {1} {2}", o.ID, props.SalePrice, props.SaleType)));
            }
            int amount;

            strA = strA.Replace("$", "").Replace("L", "");
            if (!int.TryParse(strA, out amount))
            {
                return(Failure("Cant determine amount from: " + strA));
            }
            SaleType saletype;

            if (!args.TryGetValue("saletype", out saletype))
            {
                saletype = SaleType.Original;
                //return Failure("Cant determine SaleType: " + strA);
            }

            WriteLine("Setting Ammount={0} SaleType={1} for {2}", saletype, amount, o);
            TheBotClient.Objects.SetSaleInfo(WorldSystem.GetSimulator(currentPrim), currentPrim.LocalID, saletype,
                                             amount);

            return(Success(Name + " on " + o));
        }
    // Start is called before the first frame update
    void Start()
    {
        worldScript     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <WorldSystem>();
        placementScript = GameObject.Find("PlacementManager").GetComponent <GroundPlacementController>();
        gameScript      = GameObject.Find("GameManager").GetComponent <GameManagement>();

        specificResidentHappiness = 100;

        houseCollider         = gameObject.GetComponent <BoxCollider>();
        houseCollider.enabled = true;
    }
Exemple #25
0
    public static void SaveWorld(WorldSystem worldScript)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string          path      = Application.persistentDataPath + "/world.data";
        FileStream      stream    = new FileStream(path, FileMode.Create);

        WorldData data = new WorldData(worldScript);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemple #26
0
    public LocalProcessor(LocalSystem system, GameObject instance) : base(system, instance)
    {
        this.profile              = new LocalProfile(GameObject);
        this.parentSystem         = (WorldSystem)System.Parent;
        this.shooter              = this.parentSystem.ShooterSystem.DeployInstance();
        this.shooter.Profile.IsAI = false;
        this.shooter.Profile.Rigidbody.position = new Vector3(50f, 0.5f, 50f);

        SubProcessors.Add(new LocalCameraProcessor(this.profile.CameraProfile, this.shooter));

        this.shooter.Dead += OnShooterDead;
    }
Exemple #27
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;
            List <SimObject> target = WorldSystem.GetPrimitives(args, out argsUsed);

            foreach (var o in target)
            {
                AddSuccess("" + o);
                CycWorldModule.CycModule.Show(target);
            }
            return(SuccessOrFailure());
        }
Exemple #28
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int argsUsed;

            if (!WorldPathSystem.MaintainMeshes)
            {
                return(Success("WorldObjects.MaintainMeshes = false for " + Name));
            }
            IEnumerable <SimObject> objs;

            if (!args.TryGetValue("targets", out objs))
            {
                objs = WorldSystem.GetAllSimObjects();
            }
            //if (argsUsed == 0)
            {
                int meshed          = 0;
                int unmeshed        = 0;
                int notNeedBeMEshed = 0;
                foreach (var o2 in objs)
                {
                    SimObjectPathFinding o = o2.PathFinding;
                    if (o.IsMeshed)
                    {
                        meshed++;
                        continue;
                    }
                    if (o.IsWorthMeshing)
                    {
                        unmeshed++;
                        continue;
                    }
                    notNeedBeMEshed++;
                }
                float total    = meshed + unmeshed;
                float totalAll = meshed + unmeshed + notNeedBeMEshed;

                return
                    (Success(
                         string.Format("IsMeshed/UnMeshed/UnNeeded = {0}/{1}/{2} {3:0%} complete for {4:0%} of Sim {5}",
                                       meshed, unmeshed, notNeedBeMEshed,
                                       meshed / total,
                                       total / totalAll,
                                       Name)));
            }
            foreach (SimObject o in objs)
            {
                WriteLine("MeshInfo: " + o);
                WriteLine(o.PathFinding.Mesh.DebugString());
            }
            return(Success("Ran " + Name));
        }
Exemple #29
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            ICollection PS;

            if (args.Length == 0)
            {
                PS = WorldObjects.SimAvatars;
            }
            else
            {
                int argsUsed;
                PS = WorldSystem.GetPrimitives(args.GetProperty("targets"), out argsUsed);
                if (IsEmpty(PS))
                {
                    return(Failure("Cannot find objects from " + args.str));
                }
            }
            AppendList("list", PS);
            SetResult("count", PS.Count);
            if (args.IsFFI)
            {
                return(SuccessOrFailure());
            }

            foreach (SimObject O in PS)
            {
                Primitive     foundAv = O.Prim;
                StringBuilder output  = new StringBuilder();
                output.AppendLine();
                if (foundAv.Textures == null)
                {
                    output.AppendLine("No textures yet");
                }
                else
                {
                    for (int i = 0; i < foundAv.Textures.FaceTextures.Length; i++)
                    {
                        if (foundAv.Textures.FaceTextures[i] != null)
                        {
                            Primitive.TextureEntryFace face = foundAv.Textures.FaceTextures[i];
                            AvatarTextureIndex         type = (AvatarTextureIndex)i;

                            output.AppendFormat("{0}: {1}", type, face.TextureID);
                            output.AppendLine();
                        }
                    }
                }
                AddSuccess(output.ToString());
            }
            return(SuccessOrFailure());
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length == 0)
            {
                WorldObjects.ResetSelectedObjects();
                return(Success("ResetSelectedObjects"));
            }
            string note         = "";
            var    autoDeselect = (args[0] == "re");

            if (autoDeselect)
            {
                note += "re";
                args  = args.AdvanceArgs(1);
            }
            var deSelect = (args[0] == "de");

            if (deSelect)
            {
                note += "de";
                args  = args.AdvanceArgs(1);
            }
            int used;
            List <SimObject> PS = WorldSystem.GetPrimitives(args, out used);

            if (IsEmpty(PS))
            {
                return(Failure("Cannot find objects from " + args.str));
            }
            List <uint> selectobjs = new List <uint>();
            var         fp         = PS[0].RegionHandle;

            foreach (var P in PS)
            {
                if (fp != P.RegionHandle)
                {
                    SelectObjects(deSelect, fp, selectobjs, autoDeselect);
                    fp         = P.RegionHandle;
                    selectobjs = new List <uint>();
                }
                selectobjs.Add(P.LocalID);
                uint pid = P.ParentID;
                if (pid != 0)
                {
                    selectobjs.Add(pid);
                }
            }
            SelectObjects(deSelect, fp, selectobjs, autoDeselect);
            return(Success("objects " + note + "selected " + PS.Count));
        }
Exemple #31
0
 public PlayerEntity(WorldSystem.Region tregion, Connection conn, string name)
     : base(tregion)
 {
     Name = name;
     model = "players/human_male_004";
     mod_zrot = 270;
     mod_scale = 1.5f;
     base.SetMaxHealth(100);
     base.SetHealth(100);
     Network = conn;
     SetMass(tmass);
     CanRotate = false;
     SetPosition(TheRegion.TheWorld.SpawnPoint);
     Items = new PlayerInventory(this);
 }
Exemple #32
0
 public Inventory(WorldSystem.Region tregion)
 {
     TheWorld = tregion;
 }
Exemple #33
0
 void RenderChunkInternal(WorldSystem.Region tregion, Vector3i chunkCoords, Chunk chunk)
 {
     Stopwatch sw = new Stopwatch();
     sw.Start();
     MaterialImage bmp = new MaterialImage() { Colors = new Color[BmpSize, BmpSize] };
     for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
     {
         for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
         {
             // TODO: async chunk read locker?
             BlockInternal topOpaque = BlockInternal.AIR;
             int topZ = 0;
             for (int z = 0; z < Chunk.CHUNK_SIZE; z++)
             {
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.IsOpaque())
                 {
                     topOpaque = bi;
                     topZ = z;
                 }
             }
             if (!topOpaque.Material.RendersAtAll())
             {
                 DrawImage(bmp, MaterialImages[0], x * TexWidth, y * TexWidth, Color.Transparent);
             }
             for (int z = topZ; z < Chunk.CHUNK_SIZE; z++)
             {
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.Material.RendersAtAll())
                 {
                     MaterialImage zmatbmp = MaterialImages[bi.Material.TextureID(MaterialSide.TOP)];
                     if (zmatbmp == null)
                     {
                         continue;
                     }
                     Color zcolor = Colors.ForByte(bi.BlockPaint);
                     if (zcolor.A == 0)
                     {
                         zcolor = Color.White;
                     }
                     DrawImage(bmp, zmatbmp, x * TexWidth, y * TexWidth, zcolor);
                 }
             }
         }
     }
     sw.Stop();
     Timings_A += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     Bitmap tbmp = new Bitmap(BmpSize2, BmpSize2);
     BitmapData bdat = tbmp.LockBits(new Rectangle(0, 0, tbmp.Width, tbmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
     int stride = bdat.Stride;
     // Surely there's a better way to do this!
     unsafe
     {
         byte* ptr = (byte*)bdat.Scan0;
         for (int x = 0; x < BmpSize; x++)
         {
             for (int y = 0; y < BmpSize; y++)
             {
                 Color tcol = bmp.Colors[x, y];
                 ptr[(x * 4) + y * stride + 0] = tcol.B;
                 ptr[(x * 4) + y * stride + 1] = tcol.G;
                 ptr[(x * 4) + y * stride + 2] = tcol.R;
                 ptr[(x * 4) + y * stride + 3] = tcol.A;
             }
         }
     }
     tbmp.UnlockBits(bdat);
     sw.Stop();
     Timings_B += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     DataStream ds = new DataStream();
     tbmp.Save(ds, ImageFormat.Png);
     tbmp.Dispose();
     sw.Stop();
     Timings_C += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     sw.Reset();
     sw.Start();
     lock (OneAtATimePlease) // NOTE: We can probably make this grab off an array of locks to reduce load a little.
     {
         KeyValuePair<int, int> maxes = tregion.ChunkManager.GetMaxes((int)chunkCoords.X, (int)chunkCoords.Y);
         tregion.ChunkManager.SetMaxes((int)chunkCoords.X, (int)chunkCoords.Y, Math.Min(maxes.Key, (int)chunkCoords.Z), Math.Max(maxes.Value, (int)chunkCoords.Z));
     }
     tregion.ChunkManager.WriteImage((int)chunkCoords.X, (int)chunkCoords.Y, (int)chunkCoords.Z, ds.ToArray());
     sw.Stop();
     Timings_D += sw.ElapsedTicks / (double)Stopwatch.Frequency;
 }
Exemple #34
0
 void RenderChunkInternalAngle(WorldSystem.Region tregion, Vector3i chunkCoords, Chunk chunk)
 {
     MaterialImage bmp = new MaterialImage() { Colors = new Color[BmpSize2, BmpSize2] };
     for (int z = 0; z < Chunk.CHUNK_SIZE; z++)
     {
         for (int x = 0; x < Chunk.CHUNK_SIZE; x++)
         {
             for (int y = 0; y < Chunk.CHUNK_SIZE; y++)
             {
                 // TODO: async chunk read locker?
                 BlockInternal bi = chunk.GetBlockAt(x, y, z);
                 if (bi.Material.RendersAtAll())
                 {
                     RenderBlockIntoAngle(bi, x, y, z, bmp);
                 }
             }
         }
     }
     Bitmap tbmp = new Bitmap(BmpSize2, BmpSize2);
     BitmapData bdat = tbmp.LockBits(new Rectangle(0, 0, tbmp.Width, tbmp.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
     int stride = bdat.Stride;
     // Surely there's a better way to do this!
     unsafe
     {
         byte* ptr = (byte*)bdat.Scan0;
         for (int x = 0; x < BmpSize2; x++)
         {
             for (int y = 0; y < BmpSize2; y++)
             {
                 Color tcol = bmp.Colors[x, y];
                 ptr[(x * 4) + y * stride + 0] = tcol.B;
                 ptr[(x * 4) + y * stride + 1] = tcol.G;
                 ptr[(x * 4) + y * stride + 2] = tcol.R;
                 ptr[(x * 4) + y * stride + 3] = tcol.A;
             }
         }
     }
     DataStream ds = new DataStream();
     tbmp.Save(ds, ImageFormat.Png);
     tregion.ChunkManager.WriteImageAngle((int)chunkCoords.X, (int)chunkCoords.Y, (int)chunkCoords.Z, ds.ToArray());
 }
Exemple #35
0
 public void RenderChunk(WorldSystem.Region tregion, Vector3i chunkCoords, Chunk chunk)
 {
     #if TIMINGS
     Stopwatch sw = new Stopwatch();
     sw.Start();
     #endif
     if (tregion.TheServer.CVars.g_renderblocks.ValueB)
     {
         RenderChunkInternal(tregion, chunkCoords, chunk);
     }
     if (tregion.TheServer.CVars.n_rendersides.ValueB)
     {
         RenderChunkInternalAngle(tregion, chunkCoords, chunk);
     }
     #if TIMINGS
     sw.Stop();
     Timings_General += sw.ElapsedTicks / (double)Stopwatch.Frequency;
     #endif
 }