Example #1
0
        public void DoWork(float workTime)
        {
            // Check to make sure we have everything we need.
            // If not, don't register the work time.
            if (HasAllMaterial() == false)
            {
                // Still call the callbacks though, so animations etc can be updated
                if (cbOnJobWorked != null)
                {
                    cbOnJobWorked(this);
                }

                foreach (var funcname in cbOnJobWorkedLua)
                {
                    FurnitureActions.CallFunction(funcname, this);
                }

                return;
            }

            if (cbOnJobWorked != null)
            {
                cbOnJobWorked(this);
            }
            foreach (var funcname in cbOnJobWorkedLua)
            {
                FurnitureActions.CallFunction(funcname, this);
            }

            JobTime -= workTime;

            if (JobTime <= 0)
            {
                // Do whatever is supposed to happen when this Job completes.
                if (cbOnJobCompleted != null)
                {
                    cbOnJobCompleted(this);
                }
                foreach (var funcname in cbOnJobCompletedLua)
                {
                    FurnitureActions.CallFunction(funcname, this);
                }

                if (jobRepeats == false)
                {
                    // If the Job is completely done, notify everything.
                    if (cbOnJobStopped != null)
                    {
                        cbOnJobStopped(this);
                    }
                }
                else
                {
                    // This is a repeating Job, and must be reset.
                    JobTime += JobTimeRequired;
                }
            }
        }
Example #2
0
        static FurnitureActions()
        {
            UserData.RegisterAssembly();

            _instance             = new FurnitureActions();
            _instance.myLuaScript = new Script();
            _instance.myLuaScript.Globals["Inventory"] = typeof(Inventory);
            _instance.myLuaScript.Globals["Job"]       = typeof(Job);
            _instance.myLuaScript.Globals["World"]     = typeof(World);
            //_instance.ActivateRemoteDebugger(_instance.myLuaScript);
        }
Example #3
0
        public Enterability IsEnterable()
        {
            if (string.IsNullOrEmpty(_cbIsEnterableAction))
            {
                return(Enterability.Yes);
            }

            var ret = FurnitureActions.CallFunction(_cbIsEnterableAction, this);

            return((Enterability)ret.Number);
        }
Example #4
0
        public void LoadFurnitureLua()
        {
            var filepath = Application.streamingAssetsPath;

            filepath = Path.Combine(filepath, "Base");
            filepath = Path.Combine(filepath, "LUA");
            filepath = Path.Combine(filepath, "Furniture");
            foreach (var filename in Directory.GetFiles(filepath, "*.lua"))
            {
                // Debug.Log("Loading LUA file " + filename);
                var myLuaCode = System.IO.File.ReadAllText(filename);

                FurnitureActions.LoadLua(myLuaCode);
            }
        }
Example #5
0
        /// <summary>
        /// Called by the World each 'tick' to update this object.
        /// </summary>
        /// <param name="deltaTime">The amount of time that has passed since the last tick.</param>
        public void Update(float deltaTime)
        {
            if (_lastFrameChange > 1f)
            {
                CurrentIdleFrame++;
                CurrentIdleFrame = IdleSprites == 0 ? 0 : CurrentIdleFrame % IdleSprites;
                _lastFrameChange = 0;
            }
            _lastFrameChange += deltaTime;

            ApplyDecay(deltaTime);

            if (this._cbUpdateActions != null)
            {
                FurnitureActions.CallFunctionsWithFurniture(_cbUpdateActions, this, deltaTime);
            }
        }