コード例 #1
0
 public static void OnUiAction(IntPtr ptr, int actionTypeOrdinal)
 {
     if (ptr != IntPtr.Zero)
     {
         UiAction actionType = (UiAction)actionTypeOrdinal;
         ptr.Cast <UiActionListener>()(actionType, () =>
         {
             _gs_doPendingAction();
         });
     }
 }
コード例 #2
0
 private void PrepareData(UiAction action, ChemButton?button, int?pillAmount, int?bottleAmount)
 {
     if (button != null)
     {
         SendMessage(new UiActionMessage(action, button.Amount, button.Id, button.isBuffer, null, null));
     }
     else
     {
         SendMessage(new UiActionMessage(action, null, null, null, pillAmount, bottleAmount));
     }
 }
コード例 #3
0
ファイル: ActionCommandMap.cs プロジェクト: ariugwu/sharpbox
        /// <summary>
        /// When a UiAction is passed in we need to find the corresponding CommandName so that the request can be constructed and passed to the Dispatcher for processing.
        /// </summary>
        /// <param name="defaultContext">DefaultContext is required to check for command names registered in the Dispatch CommandHub.</param>
        /// <param name="uiAction">The UiAction to lookup. If 'UseOneToOneMap' was defined then this lookup will be in the Dispatch CommandHub, otherwise in the local Map that was provided.</param>
        /// <returns>The mapped CommandName</returns>
        /// <exception cref="ArgumentNullException">Possible null candidates: UiAction, DefaultContext, DefaultContext.Dispatch, DefaultContext.Dispatch.CommandHub</exception>
        /// <exception cref="InvalidOperationException">Could be thrown by the CommandHub trying to find the CommandName that matches the UiAction</exception>
        /// <exception cref="KeyNotFoundException">Could be thrown by the UiAction = CommandName map not having the requested key.</exception>
        public CommandName GetCommandByAction(App.AppContext defaultContext, UiAction uiAction)
        {
            if (uiAction == null)
            {
                throw new ArgumentNullException("uiAction", "The UiAction passed in is null");
            }

            if (defaultContext.Dispatch == null || defaultContext.Dispatch.CommandHub == null)
            {
                throw new ArgumentNullException("defaultContext", "One of these values is null: DefaultContext, DefaultContext.Dispatch, or DefaultContext.Dispatch.CommandHub");
            }

            return(this.UseOneToOneMap ? defaultContext.Dispatch.CommandHub.First(x => x.Key.Name.Equals(uiAction.Name)).Key : this._map[uiAction]);
        }
コード例 #4
0
    /// <summary>
    /// Setup of dependencies and initial state.
    /// </summary>
    private void Start()
    {
        // Dependencies:
        timer       = TimerImpl.Instance;
        uiAction    = UiController.Instance;
        scoreAction = ScoreController.Instance;

        // Setup:
        // Register consumer of time updates:
        timer.addTimeConsumer(scoreAction.nextTime);
        //timer.addTimeConsumer(time => Debug.Log("Time left: " + time));

        // Set initial game state and start the game implicitly.
        SetGameState(currentGameState);
        // Debug.Log("GameController.Start()");
    }
コード例 #5
0
    private void OnUiAction(UiAction action, Action pendingAction)
    {
        var forbiddenForAnonymous = new List <UiAction>()
        {
            UiAction.LikeActivity, UiAction.LikeComment, UiAction.PostActivity, UiAction.PostComment
        };

        if (forbiddenForAnonymous.Contains(action) && GetSocial.GetCurrentUser().IsAnonymous)
        {
            var message = "Action " + action + " is not allowed for anonymous.";
            _console.LogD(message);
        }
        else
        {
            pendingAction();
        }
    }
コード例 #6
0
            public UiActionMessage(UiAction _action, ReagentUnit?_amount, string?_id, bool?_isBuffer, int?_pillAmount, int?_bottleAmount)
            {
                action = _action;
                if (action == UiAction.ChemButton)
                {
                    amount = _amount.GetValueOrDefault();
                    if (_id == null)
                    {
                        id = "null";
                    }
                    else
                    {
                        id = _id;
                    }

                    isBuffer = _isBuffer.GetValueOrDefault();
                }
                else
                {
                    pillAmount   = _pillAmount.GetValueOrDefault();
                    bottleAmount = _bottleAmount.GetValueOrDefault();
                }
            }
コード例 #7
0
    private void OnUiAction(UiAction action, Action pendingAction)
    {
        var forbiddenForAnonymous = new List <UiAction>()
        {
            UiAction.LikeActivity, UiAction.LikeComment, UiAction.PostActivity, UiAction.PostComment
        };

        if (forbiddenForAnonymous.Contains(action) && GetSocial.User.IsAnonymous)
        {
            var message = "Action " + action + " is not allowed for anonymous.";
#if UNITY_ANDROID
            MainThreadExecutor.Queue(() => {
                DemoUtils.ShowPopup("Info", message);
            });
#else
            DemoUtils.ShowPopup("Info", message);
#endif
            _console.LogD(message);
        }
        else
        {
            pendingAction();
        }
    }
コード例 #8
0
        public override SmartDeviceConfig GenerateConfig(SmartDeviceConfig conf)
        {
            //Generate Actions
            var ReportToolBreakageAction = new UiAction
            {
                Id     = "ReportToolBreakage",
                Type   = Components.GenericAction,
                Name   = "Report tool breakage",
                JobKey = "ToolBreakage",
                Tab    = Tabs.Actions,
                AdditionalProperties = { { "Image", AppDrawables.broken.ToString() } }
            };

            conf.Actions = new[] { ReportToolBreakageAction };

            //Generate Groups
            var WorkerGroup = new DeviceGroup
            {
                GroupName   = "Operators",
                VisibleTabs = new[] { Tabs.Dashboard },
                Dashboard   = new DashboardTabConfig {
                    Actions = new [] { ReportToolBreakageAction.Id }
                }
            };
            var LogisticGroup = new DeviceGroup
            {
                GroupName   = "Logistics",
                VisibleTabs = new[] { Tabs.Dashboard }
            };
            var MaintenanceGroup = new DeviceGroup
            {
                GroupName   = "Maintenance",
                VisibleTabs = new[] { Tabs.Dashboard }
            };

            conf.DeviceGroups = new[] { WorkerGroup, LogisticGroup, MaintenanceGroup };

            //Define UI-Elements
            var SendCancelDoubleButton = new UiComponent
            {
                Type = Components.DoubleButton,
                Id   = "submit",
                Name = "Senden",
                AdditionalProperties =
                {
                    { "TextSecondary",    "Abbrechen" },
                    { "OnClickPrimary",   "SendJob"   },
                    { "OnClickSecondary", "RemoveJob" },
                    { "Primary",          true        }
                }
            };

            //Generate UI-Layouts
            conf.Uis = new List <UiLayout>
            {
                new UiLayout()
                {
                    Id       = "ChatSendMessage",
                    Title    = "Nachricht senden",
                    Type     = Views.JobView,
                    Elements = new List <UiComponent>
                    {
                        new UiComponent
                        {
                            Type = Components.Spinner,
                            Id   = "subject",
                            Name = "Senden an"
                        },
                        new UiComponent
                        {
                            Type = Components.TextInput,
                            Id   = "text",
                            Name = "Message"
                        },
                        new UiComponent
                        {
                            Type = Components.DoubleButton,
                            Id   = "submit",
                            Name = "Bearbeiten",
                            AdditionalProperties =
                            {
                                { "TextSecondary",    "Abbrechen" },
                                { "OnClickPrimary",   "SendJob"   },
                                { "OnClickSecondary", "RemoveJob" },
                                { "Primary",          true        }
                            }
                        },
                    },
                    AdditionalProperties = { { "OnBackPressed", "RemoveJob" } }
                },
                new UiLayout()
                {
                    Id       = "ToolBreakage",
                    Title    = "Report tool breakage",
                    Type     = Views.JobView,
                    Elements = new List <UiComponent>
                    {
                        new UiComponent
                        {
                            Type = Components.Spinner,
                            Id   = "subject",
                            Name = "Maschine / Location"
                        },
                        new UiComponent
                        {
                            Type = Components.TextInput,
                            Id   = "text",
                            Name = "Article / Number"
                        },
                        new UiComponent
                        {
                            Type = Components.TextInput,
                            Id   = "description",
                            Name = "Description",
                            AdditionalProperties = { { "InputType", "multiline" } }
                        },
                        new UiComponent
                        {
                            Type = Components.Switch,
                            Id   = "helpRequested",
                            Name = "Needs assessment from Maintenance Team?"
                        },
                        new UiComponent
                        {
                            Type = Components.NumberInput,
                            Id   = "timeoffset",
                            Name = "Tool is disasselbled in ...",
                            AdditionalProperties =
                            {
                                { "Interval",          5 },
                                { "Count",            25 },
                                { "Suffix",   " Minutes" }
                            }
                        },
                        new UiComponent
                        {
                            Type = Components.Button,
                            Id   = "submit",
                            Name = "Bestätigen",
                            AdditionalProperties =
                            {
                                { "OnClick", "SendJob" },
                                { "Primary", true      }
                            }
                        },
                        SendCancelDoubleButton
                    }
                }
                //TODO: Add all remaining UIs
            };

            //Generate Users
            var users = new List <User>();

            for (var i = 0; i < 4; i++)
            {
                users.Add(new User
                {
                    Username = $"operator{i}",
                    FullName = $"Operator {i}",
                    Groups   = new[] { WorkerGroup.GroupName },
                    Devices  = new [] { new SmartDevice
                                        {
                                            DeviceName   = "A",
                                            DeviceFamily = DeviceFamily.Phone,
                                            DeviceType   = DeviceType.Android,
                                            DeviceGroups = new [] { DefaultConfig.GroupChat }
                                        },
                                        new SmartDevice
                                        {
                                            DeviceName   = "B",
                                            DeviceFamily = DeviceFamily.Watch,
                                            DeviceType   = DeviceType.Android,
                                            DeviceGroups = null
                                        }, }
                });
            }
            for (var i = 0; i < 4; i++)
            {
                users.Add(new User
                {
                    Username = $"log{i}",
                    FullName = $"Logistician {i}",
                    Groups   = new[] { WorkerGroup.GroupName },
                    Devices  = new[] { new SmartDevice
                                       {
                                           DeviceName   = "A",
                                           DeviceFamily = DeviceFamily.Phone,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = new [] { DefaultConfig.GroupChat }
                                       },
                                       new SmartDevice
                                       {
                                           DeviceName   = "B",
                                           DeviceFamily = DeviceFamily.Watch,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = null
                                       }, }
                });
            }
            for (var i = 0; i < 4; i++)
            {
                users.Add(new User
                {
                    Username = $"maintenance{i}",
                    FullName = $"Maintainer {i}",
                    Groups   = new[] { WorkerGroup.GroupName },
                    Devices  = new[] { new SmartDevice
                                       {
                                           DeviceName   = "A",
                                           DeviceFamily = DeviceFamily.Phone,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = new [] { DefaultConfig.GroupChat }
                                       },
                                       new SmartDevice
                                       {
                                           DeviceName   = "B",
                                           DeviceFamily = DeviceFamily.Watch,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = null
                                       }, }
                });
            }
            conf.Users = users;

            return(conf);
        }
コード例 #9
0
        public virtual AbstractValidator <T> LoadValidatorByUiAction(UiAction uiAction)
        {
            var validator = new InlineValidator <T>();

            return(validator);
        }
コード例 #10
0
        public override SmartDeviceConfig GenerateConfig(SmartDeviceConfig conf)
        {
            conf.AppInfo = new AppInfo
            {
                Id            = "Sample",
                Title         = "SmartDevices",
                Theme         = null,
                TitleResource = null,
                Subtitle      = "Sample App",
            };

            //Generate TabConfig
            var statusFilter = new TabFilterEntry()
            {
                Key        = "status",
                Name       = "State",
                FilterType = "state",
                Invertable = true
            };

            var textFilter = new TabFilterEntry()
            {
                Key        = "text",
                Name       = "Text",
                FilterType = "text",
                Invertable = false
            };

            var titleFilter = new TabFilterEntry()
            {
                Key        = "title",
                Name       = "Titel",
                FilterType = "text",
                Invertable = false
            };

            var textSort = new TabSortEntry()
            {
                Key = "text", Name = "Text"
            };
            var titleSort = new TabSortEntry()
            {
                Key = "title", Name = "Titel"
            };
            var dateSort = new TabSortEntry()
            {
                Key = "createdate", Name = "Create Date"
            };
            var typeSort = new TabSortEntry()
            {
                Key = "type", Name = "Type"
            };
            var stateSort = new TabSortEntry()
            {
                Key = "state", Name = "State"
            };
            var nameSort = new TabSortEntry()
            {
                Key = "name", Name = "Name"
            };
            var idSort = new TabSortEntry()
            {
                Key = "id", Name = "Id"
            };

            conf.TabConfig = new List <TabConfig>()
            {
                new TabConfig()
                {
                    Title         = "Live-Data",
                    Key           = ConfigConstants.Tabs.Livedata,
                    MainTab       = false,
                    Icon          = AppDrawables.livefeed,
                    FilterEntries = new List <TabFilterEntry>(),
                    SortEntries   = new List <TabSortEntry> {
                        nameSort, idSort
                    }
                },
                new TabConfig()
                {
                    Title           = "Jobs",
                    Key             = ConfigConstants.Tabs.Dashboard,
                    MainTab         = true,
                    ShowBadgeNumber = true,
                    Icon            = AppDrawables.job,
                    FilterEntries   = new List <TabFilterEntry>()
                    {
                        titleFilter,
                        textFilter,
                        statusFilter
                    },
                    SortEntries = new List <TabSortEntry>()
                    {
                        titleSort,
                        textSort,
                        dateSort,
                        typeSort,
                        stateSort
                    }
                },
                new TabConfig()
                {
                    Title         = "Actions",
                    Key           = ConfigConstants.Tabs.Actions,
                    MainTab       = false,
                    Icon          = AppDrawables.action,
                    FilterEntries = new List <TabFilterEntry>(),
                    SortEntries   = new List <TabSortEntry> {
                        nameSort
                    }
                }
            };

            //Generate Actions
            var ChatAction = new UiAction
            {
                Id     = "ChatAction",
                Type   = ConfigConstants.Components.GenericAction,
                Name   = "Chat",
                JobKey = "ChatSendMessage",
                Tab    = ConfigConstants.Tabs.Actions,
                AdditionalProperties = { { "Image", AppDrawables.notification.ToString() } }
            };

            conf.Actions = new[] { ChatAction };

            //Generate Groups
            var ChatGroup = new DeviceGroup
            {
                GroupName = GroupChat,
                Dashboard = new DashboardTabConfig
                {
                    Actions = new[] { ChatAction.Id }
                },
                VisibleTabs = new[] { ConfigConstants.Tabs.Actions, ConfigConstants.Tabs.Dashboard }
            };

            conf.DeviceGroups = new[] { ChatGroup };

            //Generate UiLayouts
            conf.Uis = new List <UiLayout>
            {
                new UiLayout()
                {
                    Id       = "ChatSendMessage",
                    Title    = "Nachricht senden",
                    Type     = ConfigConstants.Views.JobView,
                    Elements = new List <UiComponent>
                    {
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.Spinner,
                            Id   = "subject",
                            Name = "Senden an"
                        },
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.TextInput,
                            Id   = "text",
                            Name = "Message"
                        },
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.DoubleButton,
                            Id   = "submit",
                            Name = "Bearbeiten",
                            AdditionalProperties =
                            {
                                { "TextSecondary",    "Abbrechen" },
                                { "OnClickPrimary",   "SendJob"   },
                                { "OnClickSecondary", "RemoveJob" },
                                { "Primary",          true        }
                            }
                        },
                    },
                    AdditionalProperties = { { "OnBackPressed", "RemoveJob" } }
                },
                new UiLayout()
                {
                    Id       = "ChatConfirmMessage",
                    Title    = "Nachricht bestätigen",
                    Type     = ConfigConstants.Views.JobView,
                    Elements = new List <UiComponent>
                    {
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.TextView,
                            Id   = "subject",
                            Name = "Absender"
                        },
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.TextView,
                            Id   = "text",
                            Name = "Message"
                        },
                        new UiComponent
                        {
                            Type = ConfigConstants.Components.Button,
                            Id   = "submit",
                            Name = "Bestätigen",
                            AdditionalProperties =
                            {
                                { "OnClick", "SendJob" },
                                { "Primary", true      }
                            }
                        },
                    }
                }
            };

            //Generate Users
            var users = new List <User>();

            for (var i = 0; i < 4; i++)
            {
                users.Add(new User
                {
                    Username = $"chat{i}",
                    FullName = $"Chat-User {i}",
                    Groups   = new[] { GroupChat },
                    Devices  = new[] { new SmartDevice
                                       {
                                           DeviceName   = "A",
                                           DeviceFamily = DeviceFamily.Phone,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = new [] { ChatGroup.GroupName }
                                       },
                                       new SmartDevice
                                       {
                                           DeviceName   = "B",
                                           DeviceFamily = DeviceFamily.Watch,
                                           DeviceType   = DeviceType.Android,
                                           DeviceGroups = null
                                       }, }
                });
            }
            conf.Users = users;
            return(conf);
        }
コード例 #11
0
 public EntityCreationProperties(Type pluginType, UiAction triggeredBy)
 {
     PluginType = pluginType;
     TriggeredBy = triggeredBy;
 }
コード例 #12
0
        private void TryCreatePackage(IEntity user, UiAction action, int pillAmount, int bottleAmount)
        {
            var random = IoCManager.Resolve <IRobustRandom>();

            if (action == UiAction.CreateBottles)
            {
                var individualVolume = BufferSolution.CurrentVolume / ReagentUnit.New(bottleAmount);
                var actualVolume     = ReagentUnit.Min(individualVolume, ReagentUnit.New(30));
                for (int i = 0; i < bottleAmount; i++)
                {
                    var bottle = Owner.EntityManager.SpawnEntity("bottle", Owner.Transform.GridPosition);

                    var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume);

                    bottle.TryGetComponent <SolutionComponent>(out var bottleSolution);
                    bottleSolution?.Solution.AddSolution(bufferSolution);

                    //Try to give them the bottle
                    if (user.TryGetComponent <HandsComponent>(out var hands) &&
                        bottle.TryGetComponent <ItemComponent>(out var item))
                    {
                        if (hands.CanPutInHand(item))
                        {
                            hands.PutInHand(item);
                            continue;
                        }
                    }

                    //Put it on the floor
                    bottle.Transform.GridPosition = user.Transform.GridPosition;
                    //Give it an offset
                    var x_negative = random.Prob(0.5f) ? -1 : 1;
                    var y_negative = random.Prob(0.5f) ? -1 : 1;
                    bottle.Transform.LocalPosition += new Vector2(random.NextFloat() * 0.2f * x_negative, random.NextFloat() * 0.2f * y_negative);
                }
            }
            else //Pills
            {
                var individualVolume = BufferSolution.CurrentVolume / ReagentUnit.New(pillAmount);
                var actualVolume     = ReagentUnit.Min(individualVolume, ReagentUnit.New(50));
                for (int i = 0; i < pillAmount; i++)
                {
                    var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.GridPosition);

                    var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume);

                    pill.TryGetComponent <SolutionComponent>(out var pillSolution);
                    pillSolution?.Solution.AddSolution(bufferSolution);

                    //Try to give them the bottle
                    if (user.TryGetComponent <HandsComponent>(out var hands) &&
                        pill.TryGetComponent <ItemComponent>(out var item))
                    {
                        if (hands.CanPutInHand(item))
                        {
                            hands.PutInHand(item);
                            continue;
                        }
                    }

                    //Put it on the floor
                    pill.Transform.GridPosition = user.Transform.GridPosition;
                    //Give it an offset
                    var x_negative = random.Prob(0.5f) ? -1 : 1;
                    var y_negative = random.Prob(0.5f) ? -1 : 1;
                    pill.Transform.LocalPosition += new Vector2(random.NextFloat() * 0.2f * x_negative, random.NextFloat() * 0.2f * y_negative);
                }
            }

            UpdateUserInterface();
        }
コード例 #13
0
 public EntityCreationProperties(Type pluginType, UiAction triggeredBy)
 {
     PluginType  = pluginType;
     TriggeredBy = triggeredBy;
 }
コード例 #14
0
 public TextureCreationProperties( string pathToTexture, UiAction triggeredBy )
 {
     PathToTexture = pathToTexture;
     TriggeredBy = triggeredBy;
 }
コード例 #15
0
 private void ButtonPressed(UiAction action, string tag)
 {
     SendMessage(new UiActionMessage(action, tag));
     _window?.Close();
 }
コード例 #16
0
        private void TryCreatePackage(EntityUid user, UiAction action, string label, int pillAmount, int bottleAmount)
        {
            if (BufferSolution.TotalVolume == 0)
            {
                user.PopupMessageCursor(Loc.GetString("chem-master-window-buffer-empty-text"));
                return;
            }

            if (action == UiAction.CreateBottles)
            {
                var individualVolume = BufferSolution.TotalVolume / FixedPoint2.New(bottleAmount);
                if (individualVolume < FixedPoint2.New(1))
                {
                    user.PopupMessageCursor(Loc.GetString("chem-master-window-buffer-low-text"));
                    return;
                }

                var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(30));
                for (int i = 0; i < bottleAmount; i++)
                {
                    var bottle = _entities.SpawnEntity("ChemistryEmptyBottle01", _entities.GetComponent <TransformComponent>(Owner).Coordinates);

                    //Adding label
                    LabelComponent labelComponent = bottle.EnsureComponent <LabelComponent>();
                    labelComponent.OriginalName = _entities.GetComponent <MetaDataComponent>(bottle).EntityName;
                    string val = _entities.GetComponent <MetaDataComponent>(bottle).EntityName + $" ({label})";
                    _entities.GetComponent <MetaDataComponent>(bottle).EntityName = val;
                    labelComponent.CurrentLabel = label;

                    var bufferSolution = BufferSolution.SplitSolution(actualVolume);
                    var bottleSolution = EntitySystem.Get <SolutionContainerSystem>().EnsureSolution(bottle, "drink");

                    EntitySystem.Get <SolutionContainerSystem>().TryAddSolution(bottle, bottleSolution, bufferSolution);

                    //Try to give them the bottle
                    if (_entities.TryGetComponent <HandsComponent?>(user, out var hands) &&
                        _entities.TryGetComponent <SharedItemComponent?>(bottle, out var item))
                    {
                        if (hands.CanPutInHand(item))
                        {
                            hands.PutInHand(item);
                            continue;
                        }
                    }

                    //Put it on the floor
                    _entities.GetComponent <TransformComponent>(bottle).Coordinates = _entities.GetComponent <TransformComponent>(user).Coordinates;
                    //Give it an offset
                    bottle.RandomOffset(0.2f);
                }
            }
            else //Pills
            {
                var individualVolume = BufferSolution.TotalVolume / FixedPoint2.New(pillAmount);
                if (individualVolume < FixedPoint2.New(1))
                {
                    user.PopupMessageCursor(Loc.GetString("chem-master-window-buffer-low-text"));
                    return;
                }

                var actualVolume = FixedPoint2.Min(individualVolume, FixedPoint2.New(50));
                for (int i = 0; i < pillAmount; i++)
                {
                    var pill = _entities.SpawnEntity("pill", _entities.GetComponent <TransformComponent>(Owner).Coordinates);

                    //Adding label
                    LabelComponent labelComponent = pill.EnsureComponent <LabelComponent>();
                    labelComponent.OriginalName = _entities.GetComponent <MetaDataComponent>(pill).EntityName;
                    string val = _entities.GetComponent <MetaDataComponent>(pill).EntityName + $" ({label})";
                    _entities.GetComponent <MetaDataComponent>(pill).EntityName = val;
                    labelComponent.CurrentLabel = label;

                    var bufferSolution = BufferSolution.SplitSolution(actualVolume);
                    var pillSolution   = EntitySystem.Get <SolutionContainerSystem>().EnsureSolution(pill, "food");
                    EntitySystem.Get <SolutionContainerSystem>().TryAddSolution(pill, pillSolution, bufferSolution);

                    //Change pill Sprite component state
                    if (!_entities.TryGetComponent(pill, out SpriteComponent? sprite))
                    {
                        return;
                    }
                    sprite?.LayerSetState(0, "pill" + _pillType);

                    //Try to give them the bottle
                    if (_entities.TryGetComponent <HandsComponent?>(user, out var hands) &&
                        _entities.TryGetComponent <SharedItemComponent?>(pill, out var item))
                    {
                        if (hands.CanPutInHand(item))
                        {
                            hands.PutInHand(item);
                            continue;
                        }
                    }

                    //Put it on the floor
                    _entities.GetComponent <TransformComponent>(pill).Coordinates = _entities.GetComponent <TransformComponent>(user).Coordinates;
                    //Give it an offset
                    pill.RandomOffset(0.2f);
                }
            }

            if (_bufferSolution?.Contents.Count == 0)
            {
                _label = "";
            }

            UpdateUserInterface();
        }
コード例 #17
0
 public TextureCreationProperties(string pathToTexture, UiAction triggeredBy)
 {
     PathToTexture = pathToTexture;
     TriggeredBy   = triggeredBy;
 }