예제 #1
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "key" || variableName == "ckey")
            {
                DreamConnection newClientConnection = Program.DreamServer.GetConnectionFromCKey(variableValue.GetValueAsString());

                newClientConnection.MobDreamObject = dreamObject;
            }
            else if (variableName == "client" && variableValue != oldVariableValue)
            {
                DreamObject newClient = variableValue.GetValueAsDreamObject();
                DreamObject oldClient = oldVariableValue.GetValueAsDreamObject();

                if (newClient != null)
                {
                    Program.ClientToConnection[newClient].MobDreamObject = dreamObject;
                }
                else if (oldClient != null)
                {
                    Program.ClientToConnection[oldClient].MobDreamObject = null;
                }
            }
        }
예제 #2
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "key" || variableName == "ckey")
            {
                if (_playerManager.TryGetSessionByUsername(variableValue.GetValueAsString(), out var session))
                {
                    var connection = _dreamManager.GetConnectionBySession(session);

                    connection.MobDreamObject = dreamObject;
                }
            }
            else if (variableName == "see_invisible")
            {
                //TODO
            }
            else if (variableName == "client" && variableValue != oldVariableValue)
            {
                var newClient = variableValue.GetValueAsDreamObject();
                var oldClient = oldVariableValue.GetValueAsDreamObject();

                if (newClient != null)
                {
                    _dreamManager.GetConnectionFromClient(newClient).MobDreamObject = dreamObject;
                }
                else if (oldClient != null)
                {
                    _dreamManager.GetConnectionFromClient(oldClient).MobDreamObject = null;
                }
            }
        }
예제 #3
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "x" || variableName == "y" || variableName == "z")
            {
                int         x           = (variableName == "x") ? variableValue.GetValueAsInteger() : dreamObject.GetVariable("x").GetValueAsInteger();
                int         y           = (variableName == "y") ? variableValue.GetValueAsInteger() : dreamObject.GetVariable("y").GetValueAsInteger();
                int         z           = (variableName == "z") ? variableValue.GetValueAsInteger() : dreamObject.GetVariable("z").GetValueAsInteger();
                DreamObject newLocation = Program.DreamMap.GetTurfAt(x, y, z);

                dreamObject.SetVariable("loc", new DreamValue(newLocation));
            }
            else if (variableName == "loc")
            {
                Program.DreamStateManager.AddAtomLocationDelta(dreamObject, variableValue.GetValueAsDreamObject());

                if (oldVariableValue.Value != null)
                {
                    DreamObject oldLoc         = oldVariableValue.GetValueAsDreamObjectOfType(DreamPath.Atom);
                    DreamList   oldLocContents = oldLoc.GetVariable("contents").GetValueAsDreamList();

                    oldLocContents.RemoveValue(new DreamValue(dreamObject));
                }

                if (variableValue.Value != null)
                {
                    DreamObject newLoc         = variableValue.GetValueAsDreamObjectOfType(DreamPath.Atom);
                    DreamList   newLocContents = newLoc.GetVariable("contents").GetValueAsDreamList();

                    newLocContents.AddValue(new DreamValue(dreamObject));
                }
            }
            else if (variableName == "screen_loc")
            {
                UpdateScreenLocation(dreamObject, variableValue);
            }
        }