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; }
protected override void OnCreate() { base.OnCreate(); inter = IntervalCheckerInitializer.InitializedChecker(IntervalTime, setChecked: true); retryInter = IntervalCheckerInitializer.InitializedChecker(1.0f, setChecked: true); }
void Start() { sight.SendUpdate(new CommanderSight.Update { //Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), //Range = settings.SightRange, }); commander.SendUpdate(new CommanderStatus.Update { AllyRange = settings.AllyRange, }); action.SendUpdate(new CommanderAction.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), }); boid.SendUpdate(new BoidComponent.Update { ForwardLength = settings.ForwardLength, SepareteWeight = settings.SepareteWeight, AlignmentWeight = settings.AlignmentWeight, CohesionWeight = settings.CohesionWeight, }); domination.SendUpdate(new DominationDevice.Update { Speed = settings.CaptureSpeed, }); }
private void OnEnable() { var data = writer.Data; var update = new BaseUnitPosture.Update(); update.Interval = IntervalCheckerInitializer.InitializedChecker(inter); if (!data.Initialized) { update.Root = this.transform.rotation.ToCompressedQuaternion(); var dic = new Dictionary <PosturePoint, PostureData>(); foreach (var k in unit.GetKeys()) { var pos = new PostureData(k, unit.GetAllRotates(k)); dic.Add(pos.Point, pos); } update.Posture = new PostureInfo() { Datas = dic }; update.Initialized = true; } writer.SendUpdate(update); }
private void RealizeTurrets(ref VirtualArmy.Component army, Dictionary <EntityId, TurretInfo> turretsDatas) { army.IsActive = false; var inter = IntervalCheckerInitializer.InitializedChecker(MovementDictionary.AlarmInter); UpdateLastChecked(ref inter); army.AlarmInter = inter; SendSleepOrdersToTurret(turretsDatas, SleepOrderType.WakeUp); }
void Start() { Assert.IsNotNull(settings); writer.SendUpdate(new CommandersManager.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), SightRange = settings.SightRange, MaxRank = settings.MaxRank, }); }
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); }
void Start() { sight.SendUpdate(new StrongholdSight.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), }); stamina.SendUpdate(new DominationStamina.Update { Range = settings.DominationRange, MaxStamina = settings.MaxStamina, }); }
protected override void OnCreate() { base.OnCreate(); group = GetEntityQuery( ComponentType.ReadOnly <PlayerInfo.Component>(), ComponentType.ReadOnly <Transform>() ); interClient = IntervalCheckerInitializer.InitializedChecker(this.IntervalTime, setChecked: true); action = Query; }
public GunInfo GetGunInfo(ulong uid, int bone) { var info = new GunInfo { GunId = uid, GunTypeId = typeId, StockBullets = stock, Interval = IntervalCheckerInitializer.InitializedChecker(inter), AttachedBone = bone, }; return(info); }
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.ReadWrite <ResourceComponent.Component>(), ComponentType.ReadOnly <ResourceComponent.HasAuthority>(), ComponentType.ReadWrite <ResourceSupplyer.Component>(), ComponentType.ReadOnly <BaseUnitStatus.Component>(), ComponentType.ReadOnly <SpatialEntityId>() ); inter = IntervalCheckerInitializer.InitializedChecker(time); }
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; }
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; }
void Start() { Assert.IsNotNull(settings); factoryWriter.SendUpdate(new UnitFactory.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), ResourceMax = settings.ResourceMax, }); observerWriter.SendUpdate(new UnitArmyObserver.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), }); }
public GunInfo GetGunInfo(ulong uid) { var info = new GunInfo { GunId = uid, GunTypeId = typeId, StockBullets = stock, StockMax = stock, AttackRange = atkRange, AttackAngle = atkAngle, Interval = IntervalCheckerInitializer.InitializedChecker(inter), AttachedPosture = attached, }; return(info); }
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; }
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; }
protected override void OnUpdate() { if (interval != null) { var inter = interval.Value; if (inter.CheckTime() == false) { return; } } UpdatePlayerPosition(); var min = UpdateTowers(interval.Value.Interval); if (min < float.MaxValue) { interval = IntervalCheckerInitializer.InitializedChecker(min); } }
private void VirtualizeUnits(ref VirtualArmy.Component army, Transform trans, List <EntityId> followers) { UnityEngine.Profiling.Profiler.BeginSample("VirtualizeUnits"); army.IsActive = true; var units = army.SimpleUnits; units.Clear(); var inverse = Quaternion.Inverse(trans.rotation); var pos = trans.position; foreach (var id in followers) { Transform t = null; if (TryGetComponentObject(id, out t) == false) { continue; } Rigidbody r = null; if (TryGetComponentObject(id, out r)) { r.Sleep(); } var simple = new SimpleUnit(); simple.RelativePos = (inverse * (t.position - pos)).ToFixedPointVector3(); simple.RelativeRot = (t.rotation * inverse).ToCompressedQuaternion(); units.Add(id, simple); SendSleepOrder(id, SleepOrderType.Sleep); } army.SimpleUnits = units; var inter = IntervalCheckerInitializer.InitializedChecker(MovementDictionary.AlarmInter); UpdateLastChecked(ref inter); army.AlarmInter = inter; UnityEngine.Profiling.Profiler.EndSample(); }
private void UpdateSleepInter() { if (system == null) { return; } var inter = sleepWriter.Data.Interval; if (inter.Interval != MovementDictionary.SleepInter) { inter = IntervalCheckerInitializer.InitializedChecker(MovementDictionary.SleepInter); } inter.UpdateLastChecked(system.CurrentTime); sleepWriter.SendUpdate(new SleepComponent.Update() { Interval = inter, }); }
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; }
void Start() { Assert.IsNotNull(settings); movement.SendUpdate(new BaseUnitMovement.Update { MoveSpeed = settings.Speed, RotSpeed = settings.RotSpeed, ConsumeRate = settings.ConsumeRate, }); sight.SendUpdate(new BaseUnitSight.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), Range = settings.SightRange }); action.SendUpdate(new BaseUnitAction.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), AngleSpeed = settings.AngleSpeed, }); health.SendUpdate(new BaseUnitHealth.Update { MaxHealth = settings.MaxHp, Health = settings.MaxHp, Defense = settings.Defense, }); fuel.SendUpdate(new FuelComponent.Update { MaxFuel = settings.MaxFuel, Fuel = settings.MaxFuel, }); if (gunInitializer != null) { gunInitializer.SetGunIds(settings.GunIds); } }
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); }
void Start() { sight.SendUpdate(new CommanderSight.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), Range = settings.SightRange, }); commander.SendUpdate(new CommanderStatus.Update { AllyRange = settings.AllyRange, TeamConfig = settings.TeamConfig, }); action.SendUpdate(new CommanderAction.Update { Interval = IntervalCheckerInitializer.InitializedChecker(settings.Inter), }); //Invoke("DelayMethod", 3.5f); }
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; } }