Beispiel #1
0
        private void OnConstructionLevelChanged()
        {
            var zone = _pbsUnit.Zone;

            if (zone == null)
            {
                return;
            }

            var currentLevel = ConstructionLevelCurrent;

            if (currentLevel <= 0)
            {
                //object got deconstructed, remove from zone, add capsule to loot

                if (_contructionLootDropped)
                {
                    return;
                }

                _contructionLootDropped = true;

                using (var scope = Db.CreateTransaction())
                {
                    LootContainer.Create()
                    .AddLoot(PBSHelper.GetCapsuleDefinitionByPBSObject(_pbsUnit), 1)
                    .AddLoot(PBSHelper.GetConstructionAmmoLootOnDeconstruct(_pbsUnit))
                    .BuildAndAddToZone(zone, _pbsUnit.CurrentPosition);

                    var dockingBase = _pbsUnit as PBSDockingBase;
                    if (dockingBase != null)
                    {
                        Logger.DebugInfo("dropping loot from base");
                        PBSHelper.DropLootToZoneFromBaseItems(zone, dockingBase, false);
                    }
                    _pbsUnit.RemoveFromZone();

                    Logger.Info("pbs node got deconstructed. " + _pbsUnit.Eid + " " + _pbsUnit.ED.Name + " owner:" + _pbsUnit.Owner);
                    PBSHelper.WritePBSLog(PBSLogType.deconstructed, _pbsUnit.Eid, _pbsUnit.Definition, _pbsUnit.Owner, zoneId: zone.Id);

                    scope.Complete();
                }

                return;
            }

            if (!IsFullyConstructed)
            {
                return;
            }

            SetToDeconstruct(); //felepult, mostmar lehet lebontani is vagy barmi

            PBSHelper.WritePBSLog(PBSLogType.constructed, _pbsUnit.Eid, _pbsUnit.Definition, _pbsUnit.Owner, zoneId: zone.Id);
            SendNodeUpdate();
        }