protected override void OnCreate()
        {
            base.OnCreate();

            inter      = IntervalCheckerInitializer.InitializedChecker(IntervalTime, setChecked: true);
            retryInter = IntervalCheckerInitializer.InitializedChecker(1.0f, setChecked: true);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            factoryGroup = GetEntityQuery(
                ComponentType.ReadWrite <UnitFactory.Component>(),
                ComponentType.ReadOnly <UnitFactory.HasAuthority>(),
                ComponentType.ReadWrite <ResourceComponent.Component>(),
                ComponentType.ReadOnly <ResourceComponent.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <Position.Component>(),
                ComponentType.ReadOnly <StrongholdSight.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            factoryInter  = IntervalCheckerInitializer.InitializedChecker(1.0f);
            factoryAction = FactoryQuery;

            checkerGroup = GetEntityQuery(
                ComponentType.ReadWrite <UnitFactory.Component>(),
                ComponentType.ReadOnly <UnitFactory.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>()
                );

            checkerInter = IntervalCheckerInitializer.InitializedChecker(1.5f);
            checkAction  = CheckQuery;
        }
示例#3
0
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <RecoveryComponent.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <Transform>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(time);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadOnly <PlayerInfo.Component>(),
                ComponentType.ReadOnly <Transform>()
                );

            interClient = IntervalCheckerInitializer.InitializedChecker(this.IntervalTime, setChecked: true);

            action = Query;
        }
示例#5
0
        protected override void OnCreate()
        {
            base.OnCreate();

            unitGroup = GetEntityQuery(
                ComponentType.ReadWrite <BaseUnitHealth.Component>(),
                ComponentType.ReadOnly <BaseUnitHealth.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <Transform>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(1.0f / frequency);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <VirtualTroop.Component>(),
                ComponentType.ReadOnly <VirtualTroop.HasAuthority>(),
                ComponentType.ReadOnly <Transform>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(1.0f);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <Rigidbody>(),
                ComponentType.ReadOnly <UnitTransform>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <BuildingData>()
                );

            inter  = IntervalCheckerInitializer.InitializedChecker(period);
            action = Query;
        }
示例#8
0
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <ResourceComponent.Component>(),
                ComponentType.ReadOnly <ResourceComponent.HasAuthority>(),
                ComponentType.ReadWrite <ResourceSupplyer.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(time);
        }
示例#9
0
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <ArmyCloud.Component>(),
                ComponentType.ReadOnly <ArmyCloud.HasAuthority>(),
                ComponentType.ReadWrite <Position.Component>(),
                ComponentType.ReadOnly <Position.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(1.0f);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <StrategyOrderManager.Component>(),
                ComponentType.ReadOnly <StrategyOrderManager.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(1.0f);

            action = Query;
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <CommanderAction.Component>(),
                ComponentType.ReadOnly <CommanderAction.HasAuthority>(),
                ComponentType.ReadOnly <CommanderTeam.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <BaseUnitTarget.Component>(),
                ComponentType.ReadOnly <Transform>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(period);
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            movementGroup = GetEntityQuery(
                ComponentType.ReadOnly <UnitTransform>(),
                ComponentType.ReadWrite <MovementData>(),
                ComponentType.ReadWrite <NavPathData>(),
                ComponentType.ReadOnly <BaseUnitSight.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            intervalMovement = IntervalCheckerInitializer.InitializedChecker(periodMovement);

            deltaTime     = Time.ElapsedTime;
            movementQuery = MovementQuery;
        }
示例#13
0
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <StrongholdSight.Component>(),
                ComponentType.ReadOnly <StrongholdSight.HasAuthority>(),
                ComponentType.ReadWrite <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.HasAuthority>(),
                ComponentType.ReadOnly <HexFacility.Component>(),
                ComponentType.ReadOnly <Transform>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter             = IntervalCheckerInitializer.InitializedChecker(period);
            action            = Query;
            portalUpdateSytem = World.GetExistingSystem <StrategyHexAccessPortalUpdateSystem>();
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            group = GetEntityQuery(
                ComponentType.ReadWrite <BaseUnitSight.Component>(),
                ComponentType.ReadOnly <BaseUnitSight.HasAuthority>(),
                ComponentType.ReadWrite <UnitActionData>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadWrite <BaseUnitTarget.Component>(),
                ComponentType.ReadOnly <BaseUnitTarget.HasAuthority>(),
                ComponentType.ReadOnly <Transform>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(frequency);

            action = Query;
        }
示例#15
0
        protected override void OnCreate()
        {
            base.OnCreate();

            portalGroup = GetEntityQuery(
                ComponentType.ReadWrite <StrategyHexAccessPortal.Component>(),
                ComponentType.ReadOnly <StrategyHexAccessPortal.HasAuthority>()
                );

            facilityGroup = GetEntityQuery(
                ComponentType.ReadOnly <HexFacility.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            interAccess = IntervalCheckerInitializer.InitializedChecker(frequencyManager);

            portalQuery   = PortalQuery;
            facilityQuery = FacilityQuery;
        }
示例#16
0
        protected override void OnCreate()
        {
            base.OnCreate();

            commanderGroup = GetEntityQuery(
                ComponentType.ReadWrite <CommandersManager.Component>(),
                ComponentType.ReadOnly <CommandersManager.HasAuthority>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <Position.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            strongholdGroup = GetEntityQuery(
                ComponentType.ReadOnly <StrongholdStatus.Component>(),
                ComponentType.ReadOnly <BaseUnitStatus.Component>(),
                ComponentType.ReadOnly <Position.Component>(),
                ComponentType.ReadOnly <SpatialEntityId>()
                );

            inter = IntervalCheckerInitializer.InitializedChecker(10.0f);
        }
 protected bool CheckTime(ref IntervalChecker inter)
 {
     return(inter.CheckTime(this.CurrentTime));
 }
        private void FactoryQuery(Unity.Entities.Entity entity,
                                  ref UnitFactory.Component factory,
                                  ref ResourceComponent.Component resource,
                                  ref BaseUnitStatus.Component status,
                                  ref Position.Component position,
                                  ref StrongholdSight.Component sight,
                                  ref SpatialEntityId entityId)
        {
            if (status.State != UnitState.Alive)
            {
                return;
            }

            if (UnitUtils.IsBuilding(status.Type) == false)
            {
                return;
            }

            if (status.Order == OrderType.Idle)
            {
                return;
            }

            FollowerOrder?f_order      = null;
            SuperiorOrder?s_order      = null;
            TeamOrder?    team_order   = null;
            TurretOrder?  turret_order = null;

            FactoryOrderType orderType = FactoryOrderType.None;

            if (factory.SuperiorOrders.Count > 0)
            {
                s_order   = factory.SuperiorOrders[0];
                orderType = FactoryOrderType.Superior;
            }
            else if (factory.FollowerOrders.Count > 0)
            {
                f_order   = factory.FollowerOrders[0];
                orderType = FactoryOrderType.Follower;
            }
            else if (factory.TeamOrders.Count > 0)
            {
                team_order = factory.TeamOrders[0];
                orderType  = FactoryOrderType.Team;
            }
            else if (factory.TurretOrders.Count > 0)
            {
                turret_order = factory.TurretOrders[0];
                orderType    = FactoryOrderType.Turret;
            }

            if (orderType == FactoryOrderType.None)
            {
                return;
            }

            // calc time cost
            int   resourceCost;
            float timeCost;

            if (CalcOrderCost(out resourceCost, out timeCost, f_order, s_order, team_order) == false)
            {
                return;
            }

            //Debug.LogFormat("ResourceCost:{0} TimeCost:{1}", resourceCost, timeCost);

            if (factory.CurrentType == FactoryOrderType.None)
            {
                if (resource.Resource < resourceCost)
                {
                    //Debug.LogFormat("ResourcePoor:{0}", resource.Resource);
                    return;
                }

                factory.ProductInterval = IntervalCheckerInitializer.InitializedChecker(timeCost);
                factory.CurrentType     = orderType;
                resource.Resource      -= resourceCost;
            }

            factoryInter = factory.ProductInterval;
            if (CheckTime(ref factoryInter) == false)
            {
                return;
            }

            Coordinates?random = null;

            if (sight.StrategyVector.Side != UnitSide.None)
            {
                random = GetEmptyCoordinates(entityId.EntityId, position.Coords, sight.StrategyVector.Vector, height_buffer, factory.Containers);
            }

            if (random == null)
            {
                //Debug.LogFormat("There is no Empty");
                return;
            }

            //Debug.LogFormat("CreateUnit!");

            factory.ProductInterval = factoryInter;

            var            coords   = random.Value;//GetEmptyCoordinates(entityId.EntityId, position.Coords, height_buffer, factory.Containers);
            EntityTemplate template = null;

            bool     finished = false;
            UnitType type     = UnitType.None;

            if (s_order != null)
            {
                template = CreateSuperior(factory.SuperiorOrders, coords, out finished);
                type     = UnitType.Commander;
            }
            else if (f_order != null)
            {
                template = CreateFollower(factory.FollowerOrders, coords, f_order.Value.Customer, out finished);
                type     = UnitType.Soldier;
            }

            if (template != null)
            {
                var request = new WorldCommands.CreateEntity.Request
                              (
                    template,
                    context: new ProductOrderContext()
                {
                    f_order      = f_order,
                    s_order      = s_order,
                    type         = type,
                    strongholdId = entityId.EntityId,
                    container    = new UnitContainer(coords.ToFixedPointVector3(), ContainerState.Created)
                }
                              );
                this.CommandSystem.SendCommand(request);
            }
            else if (team_order != null)
            {
                CreateTeam(factory.TeamOrders, status.Side, entityId.EntityId, coords, out finished);
            }
            else if (turret_order != null)
            {
                // todo turret
            }

            if (finished)
            {
                factory.CurrentType = FactoryOrderType.None;
            }
        }
示例#19
0
 public EntityQuerySet(EntityQuery query, float inter, double current = double.MinValue)
 {
     this.group     = query;
     this.inter     = IntervalCheckerInitializer.InitializedChecker(inter);
     this.deltaTime = current;
 }
 protected void UpdateLastChecked(ref IntervalChecker inter)
 {
     inter.UpdateLastChecked(this.CurrentTime);
 }