Exemple #1
0
        public static void LogPlate()
        {
            ClientPlate plate = Object.FindObjectOfType <ClientPlate>();

            Logger.Log($"Plate location: {Logger.FormatPosition(plate.transform.position)}");

            Logger.Log("Before method call");

            Component component = ComponentUtil.GetPlateLocationComponent(plate);

            Logger.Log("After method call");

            Logger.Log($"Component name: {component.name}");
        }
Exemple #2
0
        public bool IsAttachStationEmptyAndClean(Component component)
        {
            if (!ComponentUtil.IsCleanAttachStation(component))
            {
                return(false);
            }

            if (component is ClientAttachStation clientAttachStation)
            {
                return(!clientAttachStation.HasItem());
            }

            return(false);
        }
        public MoveTargetAction(PlayerControls player, Component component) :
            base(player, component.transform.position, false)
        {
            Component locationComponent = ComponentUtil.GetObjectLocationComponent(component);

            if (locationComponent != null)
            {
                target = locationComponent;
            }
            else
            {
                target = component;
            }

            Logger.Log($"MoveTargetAction instantiated to {target.name}");
        }
Exemple #4
0
        public PlateHoldingAction(PlayerControls player)
        {
            this.player = player;

            plate = ComponentUtil.GetClosestComponent <ClientPlate>(PlayerUtil.GetChefPosition(player));
            state = 0;

            if (ComponentUtil.IsPlateOnComponent(plate))
            {
                currentAction = new PathFindAction(player, ComponentUtil.GetPlateLocationComponent(plate));
            }
            else
            {
                currentAction = new PathFindAction(player, plate);
            }
        }
Exemple #5
0
        public ChopIngredientAction(PlayerControls player)
        {
            this.player = player;
            state       = 0;

            workstation = ComponentUtil.GetClosestMatchingComponent <ClientWorkstation>(
                player.transform.position, IsChoppingNotBlocked
                );

            currentAction =
                new PathFindAction(
                    player,
                    workstation
                    );

            Logger.Log("ChopIngredientAction instantiated");
        }
Exemple #6
0
        public CookIngredientAction(PlayerControls player)
        {
            Logger.Log("CookIngredientAction instantiated");

            this.player = player;
            state       = 0;

            cookableContainer =
                ComponentUtil.GetClosestMatchingComponent <ClientCookableContainer>(player.transform.position,
                                                                                    IsCookablePot);
            Logger.Log($"Cookable container pos: {Logger.FormatPosition(cookableContainer.transform.position)}");
            bool cookableOnStation = false;

            foreach (var possibleCookingStation in Object.FindObjectsOfType <ClientCookingStation>())
            {
                Logger.Log($"Station pos: {Logger.FormatPosition(possibleCookingStation.transform.position)}");
                if (IsCookableOnStation(cookableContainer, possibleCookingStation))
                {
                    cookableOnStation = true;
                    cookingStation    = possibleCookingStation;
                    break;
                }
            }

            if (cookableOnStation)
            {
                currentAction =
                    new PathFindAction(
                        player,
                        cookingStation
                        );

                state = 3;
            }
            else
            {
                currentAction =
                    new PathFindAction(
                        player,
                        cookableContainer
                        );
            }
        }
Exemple #7
0
        public PlateHoldingAction(PlayerControls player, ClientPlate plate)
        {
            this.player = player;
            this.plate  = plate;
            state       = 0;

            Logger.Log("PlateHoldingAction instantiated");

            if (ComponentUtil.IsPlateOnComponent(plate))
            {
                currentAction = new PathFindAction(player, ComponentUtil.GetPlateLocationComponent(plate));
                Logger.Log("Pathfinding component?");
            }
            else
            {
                currentAction = new PathFindAction(player, plate);
                Logger.Log("Pathfinding plate?");
            }
        }
Exemple #8
0
        public bool Update()
        {
            switch (state)
            {
            case 0:
                if (currentAction.Update())
                {
                    currentAction.End();
                    state         = 1;
                    currentAction = new PickDropAction(player);
                }

                return(false);

            case 1:
                if (currentAction.Update())
                {
                    currentAction.End();

                    cookingStation = ComponentUtil.GetClosestComponent <ClientCookingStation>(player.transform.position);

                    if (IsCookableOnStation(cookableContainer, cookingStation))
                    {
                        state = 5;
                    }
                    else
                    {
                        state = 2;

                        currentAction = new PickDropAction(player);
                    }
                }

                return(false);

            case 2:
                if (currentAction.Update())
                {
                    currentAction.End();
                    state = 3;

                    currentAction =
                        new PathFindAction(
                            player,
                            cookingStation
                            );
                }

                return(false);

            case 3:
                if (currentAction.Update())
                {
                    currentAction.End();
                    state = 4;

                    currentAction = new PickDropAction(player);
                }

                return(false);

            case 4:
                if (currentAction.Update())
                {
                    currentAction.End();

                    state = 5;
                }

                return(false);

            case 5:
                if (cookableContainer.GetCookingHandler().GetCookingProgress() >=
                    cookableContainer.GetCookingHandler().AccessCookingTime)
                {
                    state = 6;

                    currentAction =
                        new PathFindAction(
                            player,
                            cookingStation
                            );
                }

                return(false);

            case 6:
                if (currentAction.Update())
                {
                    currentAction.End();

                    state = 7;

                    currentAction = new PickDropAction(player);
                }

                return(false);

            case 7:
                if (currentAction.Update())
                {
                    currentAction.End();

                    return(true);
                }

                return(false);

            default:
                return(false);
            }
        }
Exemple #9
0
        public bool Update()
        {
            switch (state)
            {
            case 0:
                if (currentAction.Update())
                {
                    currentAction.End();
                    state         = 1;
                    currentAction = new PickDropAction(player, true);
                }

                return(false);

            case 1:
                if (currentAction.Update())
                {
                    currentAction.End();

                    if (!PlayerUtil.IsCarrying(player))
                    {
                        return(true);
                    }
                    // Still holding something, for instance a pan or pot
                    Logger.Log("Still holding something after plating");
                    state = 2;

                    ClientAttachStation clientAttachStation =
                        ComponentUtil.GetClosestMatchingComponent <ClientAttachStation>(
                            player.transform.position, IsAttachStationEmptyAndClean);

                    currentAction =
                        new PathFindAction(
                            player,
                            clientAttachStation
                            );
                }

                return(false);

            case 2:
                if (currentAction.Update())
                {
                    currentAction.End();

                    state = 3;

                    currentAction = new PickDropAction(player);
                }

                return(false);

            case 3:
                if (currentAction.Update())
                {
                    currentAction.End();

                    return(true);
                }

                return(false);

            default:
                return(false);
            }
        }