Ejemplo n.º 1
0
        public static void AtStartup(RuleEngine GlobalRules)
        {
            GlobalRules.DeclarePerformRuleBook <Actor>("player joined", "[Player] : Considered when a player enters the game.", "actor");

            GlobalRules.DeclarePerformRuleBook <Actor>("player left", "[Player] : Considered when a player leaves the game.", "actor");

            GlobalRules.Perform <Actor>("player joined")
            .First
            .Do((actor) =>
            {
                MudObject.Move(actor, MudObject.GetObject(Core.SettingsObject.NewPlayerStartRoom));
                return(PerformResult.Continue);
            })
            .Name("Move to start room rule.");
        }
Ejemplo n.º 2
0
        override public MudObject ReloadObject(String Path)
        {
            Path = Path.Replace('\\', '/');

            if (NamedObjects.ContainsKey(Path))
            {
                var existing  = NamedObjects[Path];
                var newObject = CompileObject(Path);
                if (newObject == null)
                {
                    return(null);
                }

                existing.State = ObjectState.Destroyed;
                NamedObjects.Upsert(Path, newObject);
                MudObject.InitializeObject(newObject);

                //Preserve contents
                if (existing is Container && newObject is Container)
                {
                    foreach (var item in (existing as Container).EnumerateObjectsAndRelloc())
                    {
                        (newObject as Container).Add(item.Item1, item.Item2);
                        item.Item1.Location = newObject;
                    }
                }

                //Preserve location
                if (existing is MudObject && newObject is MudObject)
                {
                    if ((existing as MudObject).Location != null)
                    {
                        var loc = ((existing as MudObject).Location as Container).RelativeLocationOf(existing);
                        MudObject.Move(newObject as MudObject, (existing as MudObject).Location, loc);
                        MudObject.Move(existing as MudObject, null, RelativeLocations.None);
                    }
                }

                existing.Destroy(false);

                return(newObject);
            }
            else
            {
                return(GetObject(Path));
            }
        }
Ejemplo n.º 3
0
        public RMUD.MudObject ResetObject(string Path)
        {
            Path = Path.Replace('\\', '/');

            if (NamedObjects.ContainsKey(Path))
            {
                var existing = NamedObjects[Path];
                existing.State = ObjectState.Destroyed;

                var newObject = Activator.CreateInstance(existing.GetType()) as MudObject;
                NamedObjects.Upsert(Path, newObject);
                MudObject.InitializeObject(newObject);

                //Preserve the location of actors, and actors only.
                if (existing is Container)
                {
                    foreach (var item in (existing as Container).EnumerateObjectsAndRelloc())
                    {
                        if (item.Item1 is Actor)
                        {
                            (newObject as Container).Add(item.Item1, item.Item2);
                            item.Item1.Location = newObject;
                        }
                    }
                }

                if (existing is MudObject && (existing as MudObject).Location != null)
                {
                    var loc = ((existing as MudObject).Location as Container).RelativeLocationOf(existing);
                    MudObject.Move(newObject as MudObject, (existing as MudObject).Location, loc);
                    MudObject.Move(existing as MudObject, null, RelativeLocations.None);
                }

                existing.Destroy(false);

                return(newObject);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
 public static void RemovePlayer(Actor Actor)
 {
     GlobalRules.ConsiderPerformRule("player left", Actor);
     Actor.ConnectedClient = null;
     MudObject.Move(Actor, null);
 }