Beispiel #1
0
        public override void MaintainActiveEffects(GameContext context)
        {
            base.MaintainActiveEffects(context);

            foreach (var cmd in HotbarCommands.Where(c => c?.Command != null && c.IsActive &&
                                                     c.Command.ActivationType == CommandActivationType.Active))
            {
                // Deactivate the command if it can't be paid for
                if (cmd.Command.MaintenanceCost > Operations)
                {
                    if (IsPlayer)
                    {
                        context.AddMessage($"{cmd.Command.Name} deactivates due to lack of available operations", ClientMessageType.Failure);
                        context.AddEffect(new DeactivatedEffect(this, cmd.Command.Name));
                    }

                    cmd.IsActive = false;
                    continue;
                }

                AdjustOperationsPoints(-cmd.Command.MaintenanceCost);

                cmd.Command.ApplyEffect(context, this, Pos);
            }
        }
Beispiel #2
0
        public override void SetCommandActiveState(GameCommand command, bool isActive)
        {
            base.SetCommandActiveState(command, isActive);

            if (command == null)
            {
                return;
            }

            var match = HotbarCommands.FirstOrDefault(c => c?.Command?.Id == command.Id);

            if (match != null && command?.Id != null)
            {
                match.IsActive = isActive;
            }
        }
Beispiel #3
0
        public bool AttemptPickupItem(GameContext context, GameObjectBase item)
        {
            // TODO: this won't work once we have more items that can be picked up
            CommandPickup commandPickup = (CommandPickup)item;

            if (commandPickup.CommandId == null)
            {
                context.AddError($"{Name} attempts to pick up the command but it vanishes into the void");
                return(true);
            }

            var command = CommandFactory.CreateCommand(commandPickup.CommandId);

            if (item.IsCorrupted)
            {
                context.AddMessage($"{Name} picks up the corrupted item and is struck by a virus!", ClientMessageType.Failure);
                var message = context.CombatManager.HurtObject(context, item, this, 3, "infects", DamageType.Combination);
                context.AddMessage(message, ClientMessageType.Failure);
                return(true);
            }

            int index = HotbarCommands.IndexOf(null);

            if (index >= 0)
            {
                HotbarCommands[index] = CommandFactory.CreateCommandReference(command);
                context.AddMessage($"{Name} picks up {command.Name}", ClientMessageType.Success);
                return(true);
            }

            index = StoredCommands.IndexOf(null);
            if (index >= 0)
            {
                StoredCommands[index] = CommandFactory.CreateCommandReference(command);
                context.AddMessage($"{Name} picks up {command.Name} and stores it", ClientMessageType.Success);
                return(true);
            }

            context.AddMessage($"{Name} does not have enough free space to pick up {command.Name}", ClientMessageType.Failure);
            return(false);
        }
Beispiel #4
0
 /// <inheritdoc />
 public override bool IsCommandActive(GameCommand command) =>
 HotbarCommands.Any(c => c != null && c.IsActive && c.Command == command);