Beispiel #1
0
        public override void ApplyEffect(GameContext context, Actor executor, Pos2D pos)
        {
            if (!executor.IsPlayer)
            {
                context.AddError($"{executor.Name} tries to invoke the {Name} command but does not have permission.");
                return;
            }

            context.Level.MarkedPos = executor.Pos;

            if (executor.IsPlayer || context.CanPlayerSee(executor.Pos))
            {
                context.AddMessage($"{executor.Name} marks their current position.", ClientMessageType.Success);
                context.AddEffect(new CellMarkedEffect(executor.Pos));
            }
        }
Beispiel #2
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);
        }