Beispiel #1
0
 protected override void ClientObserving(ClientObjectData data, bool isObserving)
 {
     if (isObserving)
     {
         ConstructionSystem.ClientTryStartAction(allowReplacingCurrentConstructionAction: false);
     }
 }
        public void TestHandleConstructionFinishedWrongId()
        {
            ConstructionSystem system = SetupMock();
            var testMessage           = new Systems.Construction.Messages.ConstructionFinished(Guid.NewGuid(), "");

            system.Actor.Tell(testMessage);
            ExpectMsg <CouldNotProcessMessage>(msg => msg.Message.Equals(testMessage) && msg.Reason == CouldNotProcessMessage.EntityNotFound);
        }
        public void TestWaitingForResources()
        {
            var guid = new Guid();
            ConstructionSystem system = SetupMock();

            system.Actor.Tell(new Systems.Construction.Messages.WaitingForResources(guid));
            ExpectMsg <Systems.Construction.Messages.WaitingForResources>(bn => bn.ComponentId == guid);
        }
        public void TestBuilderNeeded()
        {
            var guid = new Guid();
            ConstructionSystem system = SetupMock();

            system.Actor.Tell(new Systems.Construction.Messages.BuilderNeeded(guid));
            ExpectMsg <Systems.Construction.Messages.BuilderNeeded>(bn => bn.ComponentId == guid);
        }
    public void Init()
    {
        constructionSystem = new ConstructionSystem(this);

        countSystem = new CountSystem(this);

        motionSystem = new MotionSystem(this);

        timingststem = new TimingSystem(this);
    }
Beispiel #6
0
 public override bool SharedIsInsideCharacterInteractionArea(
     ICharacter character,
     IStaticWorldObject worldObject,
     bool writeToLog,
     CollisionGroup requiredCollisionGroup = null)
 {
     return(ConstructionSystem.CheckCanInteractForConstruction(character,
                                                               worldObject,
                                                               writeToLog,
                                                               checkRaidblock: true));
 }
Beispiel #7
0
        private void ValidateCanBuild(
            Vector2Ushort tilePosition,
            bool logErrors,
            out string errorMessage,
            out bool canPlace,
            out bool isTooFar)
        {
            isTooFar = false;
            canPlace = this.protoStaticObject.CheckTileRequirements(tilePosition,
                                                                    character: null,
                                                                    out var errorCodeOrMessage,
                                                                    logErrors: logErrors);

            errorMessage = ConstructionSystem.SharedConvertCodeOrErrorMessageToString(errorCodeOrMessage);
        }
Beispiel #8
0
    //// MonoBehaviour methods
    void Awake()
    {
        Instance = this;

        // Meta
        _gameSetup = Resources.Load("Data/GameSetup") as GameSetup;

        // Map
        _mapObject = GameObject.Find("Map");
        if (_mapObject == null)
        {
            SetupErrorMessage("Map game object not linked");
        }
        else
        {
            _core        = _mapObject.transform.Find("Core").gameObject;
            _spawnPoints = _mapObject.transform.Find("SpawnPoints").gameObject;
        }

        // IO/Input/UI
        _inputControllerReference = GameObject.Find("UICanvas").GetComponent <InputController>();
        if (_inputControllerReference == null)
        {
            SetupErrorMessage("InputController game object not linked");
        }

        // Construction System
        Transform constructionsParent = transform.Find("Constructions");

        _constructionSystem = new ConstructionSystem(constructionsParent);

        // Projectile system
        Transform projectilesParent = transform.Find("Projectiles");

        _projectileSystem = new ProjectileSystem(projectilesParent);

        // Enemy System
        Transform enemiesParent = transform.Find("Enemies");

        _spawn = new SpawnSystem(enemiesParent);

        // Register notification callbacks
        Input.RegisterMouseMovementListener(_constructionSystem.OnMouseChange);
        Input.RegisterMouseClickListener(_constructionSystem.OnMouseClick);
        RegisterInteractionChangedListener(_constructionSystem.OnPlayerInteractionChanged);

        RegisterInteractionChangedListener(_inputControllerReference.OnPlayerInteractionChanged);
    }
Beispiel #9
0
        private static void OnValidate(
            Vector2Ushort tilePosition,
            bool logErrors,
            out string errorMessage,
            out bool canPlace,
            out bool isTooFar)
        {
            currentSelectedProtoExplosive.SharedValidatePlacement(
                Client.Characters.CurrentPlayerCharacter,
                tilePosition,
                logErrors: logErrors,
                canPlace: out canPlace,
                isTooFar: out isTooFar,
                errorCodeOrMessage: out var errorCodeOrMessage);

            errorMessage = ConstructionSystem.SharedConvertCodeOrErrorMessageToString(errorCodeOrMessage);
        }
Beispiel #10
0
        public static bool SharedCheckCanInteract(
            ICharacter character,
            IWorldObject worldObject,
            bool writeToLog)
        {
            if (worldObject is null ||
                worldObject.IsDestroyed)
            {
                return(false);
            }

            var staticWorldObject = (IStaticWorldObject)worldObject;

            return(ConstructionSystem.CheckCanInteractForConstruction(character,
                                                                      staticWorldObject,
                                                                      writeToLog,
                                                                      checkRaidblock: true));
        }
        public void TestMessagesFromComponent()
        {
            var scene = new Scene();
            ConstructionSystem system = SetupMock(scene);
            var building = new Systems.Construction.Building()
            {
                Name   = "Test",
                Stages =
                {
                    new Systems.Construction.Building.Stage()
                    {
                        NeededResources = new Dictionary <string, int>
                        {
                            { "Wood", 2 }
                        },
                        Steps = 2,
                    },
                }
            };

            system.AddBuilding(building);
            var component = new ConstructionSite()
            {
                Building = "Test",
            };
            var entity = new Entity
            {
                component,
            };

            scene.Entities.Add(entity);

            Assert.NotNull(entity.Get <ConstructionSite>());
            Assert.Null(entity.Get <Components.Building>());
            system.Actor.Tell(new Systems.Construction.Messages.ConstructionFinished(entity.Id, component.Building));
            ExpectNoMsg(500);
            Assert.Null(entity.Get <ConstructionSite>());
            Components.Building entBuilding = entity.Get <Components.Building>();
            Assert.NotNull(building);
            Assert.Equal(component.Building, entBuilding.Name);
        }
 protected override void ClientItemUseStart(ClientItemData data)
 {
     ConstructionSystem.ClientTryStartAction(allowReplacingCurrentConstructionAction: true);
 }
 protected override bool ClientItemUseFinish(ClientItemData data)
 {
     ConstructionSystem.ClientTryAbortAction();
     // never play "use" sound
     return(false);
 }
 protected override void ClientItemUseStart(ClientItemData data)
 {
     ConstructionSystem.ClientTryStartAction();
 }
Beispiel #15
0
 private void Awake()
 {
     instance = this;
 }