Beispiel #1
0
        private void Unsubscribe(AUnitElementData elementData) {
            _subscriptions[elementData].ForAll(d => d.Dispose());
            _subscriptions.Remove(elementData);

            D.AssertNotNull(HQElementData);    // UNCLEAR when HQElementData gets nulled when elementData == HQElementData
            if (elementData == HQElementData) {
                HQElementData.intelCoverageChanged -= HQElementIntelCoverageChangedEventHandler;
            }
        }
Beispiel #2
0
 private void UpdateElementParentName(AUnitElementData elementData) {
     //TODO something more than just assigning a parent name?
     //D.Log(ShowDebugLog, "{0}.ParentName changing to {1}.", elementData.Name, ParentName);
     elementData.ParentName = ParentName;    // the name of the fleet, not the command
 }
Beispiel #3
0
        public virtual void RemoveElement(AUnitElementData elementData) {
            bool isRemoved = _elementsData.Remove(elementData);
            D.Assert(isRemoved, elementData.DebugName);

            RefreshComposition();
            Unsubscribe(elementData);
            RecalcPropertiesDerivedFromCombinedElements();
        }
Beispiel #4
0
        public virtual void AddElement(AUnitElementData elementData) {
            D.Assert(!_elementsData.Contains(elementData), elementData.DebugName);
            __ValidateOwner(elementData);
            UpdateElementParentName(elementData);
            _elementsData.Add(elementData);

            RefreshComposition();
            Subscribe(elementData);
            RecalcPropertiesDerivedFromCombinedElements();
        }
Beispiel #5
0
 private void __ValidateOwner(AUnitElementData elementData) {
     D.AssertNotEqual(Owner, TempGameValues.NoPlayer, "Owner should be set before adding elements.");
     if (elementData.Owner == TempGameValues.NoPlayer) {
         D.Warn("{0} owner should be set before adding element to {1}.", elementData.Name, DebugName);
         elementData.Owner = Owner;
     }
     else if (elementData.Owner != Owner) {
         D.Warn("{0} owner {1} is different from {2} owner {3}.", elementData.Name, elementData.Owner, DebugName, Owner);
         elementData.Owner = Owner;
     }
 }
Beispiel #6
0
 private void HQElementDataPropChangingHandler(AUnitElementData newHQElementData) {
     HandleHQElementDataChanging(newHQElementData);
 }
Beispiel #7
0
 protected virtual void HandleHQElementDataChanging(AUnitElementData newHQElementData) {
     //D.Log(ShowDebugLog, "{0}.HQElementData is about to change.", DebugName);
     var previousHQElementData = HQElementData;
     if (previousHQElementData != null) {
         previousHQElementData.intelCoverageChanged -= HQElementIntelCoverageChangedEventHandler;
         previousHQElementData.topographyChanged -= HQElementTopographyChangedEventHandler;
     }
 }
Beispiel #8
0
 protected virtual void Subscribe(AUnitElementData elementData) {
     _subscriptions.Add(elementData, new List<IDisposable>());
     IList<IDisposable> anElementsSubscriptions = _subscriptions[elementData];
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.CurrentHitPoints, ElementCurrentHitPtsPropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.MaxHitPoints, ElementMaxHitPtsPropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, CombatStrength>(ed => ed.DefensiveStrength, ElementDefensiveStrengthPropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, CombatStrength>(ed => ed.OffensiveStrength, ElementOffensiveStrengthPropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, RangeDistance>(ed => ed.WeaponsRange, ElementWeaponsRangePropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, RangeDistance>(ed => ed.SensorRange, ElementSensorRangePropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.Science, ElementSciencePropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.Culture, ElementCulturePropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.Income, ElementIncomePropChangedHandler));
     anElementsSubscriptions.Add(elementData.SubscribeToPropertyChanged<AUnitElementData, float>(ed => ed.Expense, ElementExpensePropChangedHandler));
 }
 public override void RemoveElement(AUnitElementData elementData) {
     base.RemoveElement(elementData);
     Category = GenerateCmdCategory(UnitComposition);
 }
Beispiel #10
0
 protected override void HandleHQElementDataChanging(AUnitElementData newHQElementData) {
     base.HandleHQElementDataChanging(newHQElementData);
     D.Log(ShowDebugLog, "{0}: new HQ {1} is being assigned a CombatStance of {2}.", DebugName, newHQElementData.Name, ShipCombatStance.Defensive.GetValueName());
     (newHQElementData as ShipData).CombatStance = ShipCombatStance.Defensive;
 }
Beispiel #11
0
 protected override void Subscribe(AUnitElementData elementData) {
     base.Subscribe(elementData);
     IList<IDisposable> anElementsSubscriptions = _subscriptions[elementData];
     ShipData shipData = elementData as ShipData;
     anElementsSubscriptions.Add(shipData.SubscribeToPropertyChanged<ShipData, float>(ed => ed.FullSpeedValue, ShipFullSpeedPropChangedHandler));
 }
 public AUnitElementReport(AUnitElementData data, Player player, IUnitElement_Ltd item) : base(data, player, item) { }