Exemplo n.º 1
0
        public override void OnObjectCreated(DreamObject dreamObject, DreamProcArguments creationArguments)
        {
            base.OnObjectCreated(dreamObject, creationArguments);

            _dreamManager.WorldContentsList = dreamObject.GetVariable("contents").GetValueAsDreamList();

            DreamValue log = dreamObject.ObjectDefinition.Variables["log"];

            dreamObject.SetVariable("log", log);

            DreamValue fps = dreamObject.ObjectDefinition.Variables["fps"];

            if (fps.Value != null)
            {
                _cfg.SetCVar(CVars.NetTickrate, fps.GetValueAsInteger());
            }

            DreamValue view = dreamObject.ObjectDefinition.Variables["view"];

            if (view.TryGetValueAsString(out string viewString))
            {
                _viewRange = new ViewRange(viewString);
            }
            else
            {
                _viewRange = new ViewRange(view.GetValueAsInteger());
            }
        }
Exemplo n.º 2
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            switch (variableName)
            {
            case "x":
            case "y":
            case "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 = _dreamMapManager.GetTurf(x, y, z);

                dreamObject.SetVariable("loc", new DreamValue(newLocation));
                break;
            }

            case "loc": {
                EntityUid entity = _atomManager.GetAtomEntity(dreamObject);
                if (!_entityManager.TryGetComponent <TransformComponent>(entity, out var transform))
                {
                    return;
                }

                if (variableValue.TryGetValueAsDreamObjectOfType(DreamPath.Atom, out DreamObject loc))
                {
                    EntityUid locEntity = _atomManager.GetAtomEntity(loc);

                    transform.AttachParent(locEntity);
                    transform.LocalPosition = Vector2.Zero;
                }
                else
                {
                    transform.AttachParent(_mapManager.GetMapEntityId(MapId.Nullspace));
                }

                break;
            }

            case "screen_loc":
                UpdateScreenLocation(dreamObject, variableValue);
                break;
            }
        }
Exemplo n.º 3
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "fps")
            {
                dreamObject.SetVariable("tick_lag", new DreamValue(10.0 / variableValue.GetValueAsInteger()));
            }
        }
Exemplo n.º 4
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "len")
            {
                DreamList list   = (DreamList)dreamObject;
                int       newLen = variableValue.GetValueAsInteger();

                list.Resize(newLen);
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "fps")
            {
                dreamObject.SetVariable("tick_lag", new DreamValue(10.0f / variableValue.GetValueAsInteger()));
            }
            else if (variableName == "maxz")
            {
                int newMaxZ = variableValue.GetValueAsInteger();

                if (newMaxZ < oldVariableValue.GetValueAsInteger())
                {
                    throw new NotImplementedException("Cannot set maxz lower than previous value");
                }

                while (Program.DreamMap.Levels.Count < newMaxZ)
                {
                    Program.DreamMap.AddLevel();
                }
            }
        }
Exemplo n.º 7
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            switch (variableName)
            {
            case "fps":
                _cfg.SetCVar(CVars.NetTickrate, variableValue.GetValueAsInteger()); break;

            case "maxz":
                _dreamMapManager.SetZLevels(variableValue.GetValueAsInteger()); break;

            case "log":
                if (variableValue.TryGetValueAsString(out var logStr))
                {
                    dreamObject.SetVariableValue("log", new DreamValue(_dreamRscMan.LoadResource(logStr)));
                }
                else if (!variableValue.TryGetValueAsDreamResource(out _))
                {
                    dreamObject.SetVariableValue("log", new DreamValue(new ConsoleOutputResource()));
                }
                break;
            }
        }
Exemplo n.º 8
0
        public override void OnObjectCreated(DreamObject dreamObject, DreamProcArguments creationArguments)
        {
            base.OnObjectCreated(dreamObject, creationArguments);

            ContentsList = dreamObject.GetVariable("contents").GetValueAsDreamList();

            dreamObject.SetVariable("log", new DreamValue(new ConsoleOutputResource()));

            DreamValue fps = dreamObject.ObjectDefinition.Variables["fps"];

            if (fps.Value != null)
            {
                dreamObject.SetVariable("tick_lag", new DreamValue(10.0f / fps.GetValueAsInteger()));
            }

            //New() is not called here
        }
Exemplo n.º 9
0
        private static int GetNext(DreamObject regexInstance, DreamValue startParam, bool isGlobal)
        {
            if (startParam == DreamValue.Null)
            {
                if (isGlobal)
                {
                    DreamValue nextVar = regexInstance.GetVariable("next");

                    return((nextVar != DreamValue.Null) ? nextVar.GetValueAsInteger() : 1);
                }
                else
                {
                    return(1);
                }
            }
            else
            {
                return(startParam.GetValueAsInteger());
            }
        }
Exemplo n.º 10
0
        public override void OnVariableSet(DreamObject dreamObject, string variableName, DreamValue variableValue, DreamValue oldVariableValue)
        {
            base.OnVariableSet(dreamObject, variableName, variableValue, oldVariableValue);

            if (variableName == "len")
            {
                DreamList list   = (DreamList)dreamObject;
                int       newLen = variableValue.GetValueAsInteger();

                if (newLen > list.GetLength())
                {
                    for (int i = list.GetLength(); i < newLen; i++)
                    {
                        list.AddValue(new DreamValue((DreamObject)null));
                    }
                }
                else
                {
                    list.Cut(newLen + 1, list.GetLength() + 1);
                }
            }
        }