Пример #1
0
 public static BaseUnitTarget.Snapshot DefaultSnapshot(this BaseUnitTarget.Snapshot snapshot)
 {
     snapshot.HexInfo    = TargetUtils.DefaultTargetHexInfo();
     snapshot.FrontLine  = TargetUtils.DefaultTargetFrontLineInfo();
     snapshot.State      = TargetState.None;
     snapshot.TargetUnit = TargetUtils.DefaultTargetInfo();
     snapshot.PowerRate  = 1.0f;
     return(snapshot);
 }
Пример #2
0
        private static void SwitchType(EntityTemplate template, UnitType type, string writeAccess)
        {
            switch (type)
            {
            case UnitType.Soldier:
                template.AddComponent(new BulletComponent.Snapshot(), writeAccess);
                template.AddComponent(new PostureAnimation.Snapshot(), writeAccess);
                template.AddComponent(new DominationDevice.Snapshot {
                    Type = DominationDeviceType.Capturing
                }, writeAccess);
                template.AddComponent(new SleepComponent.Snapshot(), writeAccess);
                break;

            case UnitType.Commander:
                template.AddComponent(new BulletComponent.Snapshot(), writeAccess);
                template.AddComponent(new CommanderStatus.Snapshot {
                    Order = new OrderPair {
                        Self = OrderType.Idle, Upper = OrderType.Idle
                    },
                }, writeAccess);
                template.AddComponent(new CommanderTeam.Snapshot {
                    FollowerInfo = new FollowerInfo {
                        Followers = new List <EntityId>(), UnderCommanders = new List <EntityId>()
                    },
                    SuperiorInfo  = new SuperiorInfo(),
                    TargetInfoSet = TargetUtils.DefaultTargteInfoSet()
                }, writeAccess);
                template.AddComponent(new CommanderSight.Snapshot {
                    WarPowers = new List <WarPower>()
                }, writeAccess);
                template.AddComponent(new CommanderAction.Snapshot {
                    ActionType = CommandActionType.None
                }, writeAccess);
                template.AddComponent(new PostureAnimation.Snapshot(), writeAccess);
                template.AddComponent(new DominationDevice.Snapshot {
                    Type = DominationDeviceType.Capturing
                }, writeAccess);
                template.AddComponent(new BoidComponent.Snapshot(), writeAccess);
                template.AddComponent(new VirtualArmy.Snapshot {
                    SimpleUnits = new Dictionary <EntityId, SimpleUnit>()
                }, writeAccess);
                break;

            case UnitType.Supply:
                template.AddComponent(new BulletComponent.Snapshot(), writeAccess);
                template.AddComponent(new PostureAnimation.Snapshot(), writeAccess);
                template.AddComponent(new ResourceComponent.Snapshot(), writeAccess);
                template.AddComponent(new ResourceTransporter.Snapshot(), writeAccess);
                break;

            case UnitType.Stronghold:
                AddStrongholdTypeComponents(template, writeAccess);
                template.AddComponent(new RecoveryComponent.Snapshot {
                    State = RecoveryState.Supplying
                }, writeAccess);
                template.AddComponent(new VirtualArmy.Snapshot {
                    SimpleUnits = new Dictionary <EntityId, SimpleUnit>()
                }, writeAccess);
                //var commandersQuery = InterestQuery.Query(Constraint.Component<CommanderStatus.Component>())
                //                        .FilterResults(Position.ComponentId, BaseUnitStatus.ComponentId);
                //var commanderInterest = InterestTemplate.Create().AddQueries<StrongholdStatus.Component>(commandersQuery);
                //template.AddComponent(commanderInterest.ToSnapshot(), writeAccess);
                break;

            case UnitType.HeadQuarter:
                AddStrongholdTypeComponents(template, writeAccess);
                template.AddComponent(new StrategyOrderManager.Snapshot {
                }, writeAccess);
                template.AddComponent(new VirtualArmy.Snapshot {
                    SimpleUnits = new Dictionary <EntityId, SimpleUnit>()
                }, writeAccess);
                //var strongholdQuery = InterestQuery.Query(Constraint.Component<StrongholdStatus.Component>())
                //                      .FilterResults(Position.ComponentId, BaseUnitStatus.ComponentId);
                //var strongholdInterest = InterestTemplate.Create().AddQueries<StrategyOrderManager.Component>(strongholdQuery);
                //template.AddComponent(strongholdInterest.ToSnapshot(), writeAccess);
                break;

            case UnitType.Turret:
                template.AddComponent(new BulletComponent.Snapshot(), writeAccess);
                template.AddComponent(new PostureAnimation.Snapshot(), writeAccess);
                template.AddComponent(new TurretComponent.Snapshot(), writeAccess);
                template.AddComponent(new SleepComponent.Snapshot(), writeAccess);
                break;

            case UnitType.ArmyCloud:
                template.AddComponent(new ArmyCloud.Snapshot {
                }, writeAccess);
                break;
            }
        }