Ejemplo n.º 1
0
    public void DoWork(float workTime)
    {
        // We don't know if the Job can actually be worked, but still call the callbacks
        // so that animations and whatnot can be updated.
        if (cbJobWorked != null)
        {
            cbJobWorked(this);
        }

        if (cbJobWorkedLua != null)
        {
            foreach (string luaFunction in cbJobWorkedLua.ToList())
            {
                FurnitureActions.CallFunction(luaFunction, this);
            }
        }

        // Check to make sure we actually have everything we need.
        // If not, don't register the work time.
        if (HasAllMaterial() == false)
        {
            ////Debug.LogError("Tried to do work on a job that doesn't have all the material.");
            return;
        }

        jobTime -= workTime;

        if (jobTime <= 0)
        {
            // Do whatever is supposed to happen with a job cycle completes.
            if (cbJobCompleted != null)
            {
                cbJobCompleted(this);
            }

            foreach (string luaFunction in cbJobCompletedLua.ToList())
            {
                FurnitureActions.CallFunction(luaFunction, this);
            }

            if (jobRepeats == false)
            {
                // Let everyone know that the job is officially concluded
                if (cbJobStopped != null)
                {
                    cbJobStopped(this);
                }
            }
            else
            {
                // This is a repeating job and must be reset.
                jobTime += jobTimeRequired;
            }
        }
    }
Ejemplo n.º 2
0
    public string GetSpriteName()
    {
        if (getSpriteNameAction == null || getSpriteNameAction.Length == 0)
        {
            return(objectType);
        }

        DynValue ret = FurnitureActions.CallFunction(getSpriteNameAction, this);

        return(ret.String);
    }
Ejemplo n.º 3
0
    public ENTERABILITY IsEnterable()
    {
        if (isEnterableAction == null || isEnterableAction.Length == 0)
        {
            return(ENTERABILITY.Yes);
        }

        //FurnitureActions.CallFunctionsWithFurniture(isEnterableActions.ToArray(), this);
        DynValue ret = FurnitureActions.CallFunction(isEnterableAction, this);

        return((ENTERABILITY)ret.Number);
    }
Ejemplo n.º 4
0
    // Checks whether the given floor type is allowed to be built on the tile.
    // TODO Export this kind of check to an XML/LUA file for easier modding of floor types.
    private bool CanBuildTileTypeHere(Tile t, TileType tileType)
    {
        DynValue value = FurnitureActions.CallFunction(tileType.CanBuildHereLua, t);

        if (value != null)
        {
            return(value.Boolean);
        }
        else
        {
            Debug.ULogChannel("Lua", "Found no lua function " + tileType.CanBuildHereLua);

            return(false);
        }
    }
Ejemplo n.º 5
0
 private void InvokeContextMenuLuaAction(string luaFunction, Character character)
 {
     FurnitureActions.CallFunction(luaFunction, this, character);
 }