예제 #1
0
        public void OnNewEntity(ComponentEntityTuple <AntivirusEnhancement, ItemStorage> tuple)
        {
            var itemStorage = tuple.Component2;

            itemStorage.Items[AnalysisTargetStorageLocation] = new AnalysisTargetItemContainer(_captureMatcherGroup);

            if (_entityFactoryProvider.TryCreateItem(AnalyserActivator.Archetype, tuple.Entity.Id, null, out var activatorEntityTuple) == false)
            {
                throw new SimulationException($"{AnalyserActivator.Archetype} archetype not registered");
            }
            itemStorage.Items[AnalysisActivatorStorageLocation] = new AnalysisActivatorItemContainer()
            {
                Item = activatorEntityTuple.Entity.Id,
            };
            itemStorage.Items[AnalysisOutputStorageLocation] = new AnalysisOutputItemContainer(_outputMatcherGroup);
        }
예제 #2
0
        public void OnNewEntity(ComponentEntityTuple <TransferEnhancement, ItemStorage> tuple)
        {
            var itemStorage = tuple.Component2;

            itemStorage.Items[TransferStorageLocation] = new TransferItemContainer();

            ComponentEntityTuple <CurrentLocation, Owner> activatorEntityTuple;

            if (_entityFactoryProvider.TryCreateItem(Archetypes.TransferActivator.Archetype.Name, tuple.Entity.Id, null, out activatorEntityTuple) == false)
            {
                throw new SimulationException($"{Archetypes.TransferActivator.Archetype.Name} archetype not registered");
            }
            itemStorage.Items[TransferActivatorStorageLocation] = new TransferActivatorTargetItemContainer()
            {
                Item = activatorEntityTuple.Entity.Id,
            };
        }
예제 #3
0
        public void OnNewEntity(ComponentEntityTuple <GarbageDisposalEnhancement, ItemStorage> tuple)
        {
            var itemStorage = tuple.Component2;

            itemStorage.Items[GarbageDisposalTargetStorageLocation] = new GarbageDisposalTargetItemContainer();

            if (_entityFactoryProvider.TryCreateItem(GarbageDisposalActivatorArchetypeName, tuple.Entity.Id, null, out var activatorEntityTuple))
            {
                itemStorage.Items[GarbageDisposalActivatorStorageLocation] = new GarbageDisposalActivatorItemContainer()
                {
                    Item = activatorEntityTuple.Entity.Id,
                };
            }
            else
            {
                throw new SimulationException($"{GarbageDisposalActivatorArchetypeName} archetype not registered");
            }
        }
예제 #4
0
 protected override bool TryHandleCommand(CreateItemCommand command, int currentTick, bool handlerEnabled)
 {
     if (handlerEnabled &&
         string.IsNullOrEmpty(command.Archetype) == false &&
         _subsystemMatcherGroup.TryGetMatchingEntity(command.SystemId, out var systemTuple) &&
         _entityFactoryProvider.TryCreateItem(command.Archetype, command.SystemId, null, out var itemTuple))
     {
         if (command.ContainerType != null &&
             systemTuple.Component2.TryGetItemContainer(command.ContainerType, out var itemContainer) &&
             itemContainer.CanCapture(itemTuple.Entity.Id))
         {
             itemContainer.Item = itemTuple.Entity.Id;
             return(true);
         }
         if (systemTuple.Component2.TryGetEmptyContainer(out var emptyItemContainer, out var containerIndex))
         {
             emptyItemContainer.Item = itemTuple.Entity.Id;
             return(true);
         }
         itemTuple.Entity.Dispose();
         return(false);
     }
     return(false);
 }