public static void ServerTryAddMark(IStaticWorldObject tradingStation)
        {
            var owners = WorldObjectOwnersSystem.SharedGetOwners(tradingStation);

            if (owners.Count == 0)
            {
                // no owners - incomplete trading station
                // (first owner set when the trading station instance spawned and ServerOnBuilt method called in ProtoTradingStation)
                return;
            }

            if (!ServerIsTradingStationHasActiveLots(tradingStation))
            {
                return;
            }

            if (!ServerActiveTradingStations.Add(tradingStation))
            {
                // already added
                return;
            }

            var allOnlinePlayers = Server.Characters.EnumerateAllPlayerCharacters(onlyOnline: true);

            foreach (var onlinePlayer in allOnlinePlayers)
            {
                var isOwner = owners.Contains(onlinePlayer.Name);
                var mark    = new TradingStationMark(tradingStation.Id,
                                                     tradingStation.TilePosition,
                                                     isOwner);
                Instance.CallClient(onlinePlayer,
                                    _ => _.ClientRemote_MarkAdded(mark));
            }
        }
Example #2
0
        public LotInfoEntityViewModel(TradingStationMark mark, TradingStationLotInfo lot, bool isBuying)
        {
            var worldBoundsOffset = Api.Client.World.WorldBounds.Offset;

            this.worldX              = (ushort)(mark.TilePosition.X - worldBoundsOffset.X);
            this.worldY              = (ushort)(mark.TilePosition.Y - worldBoundsOffset.Y);
            this.isBuying            = isBuying;
            this.isOwner             = mark.IsOwner;
            this.name                = lot.ProtoItem.Name;
            this.qty                 = lot.LotQuantity;
            this.count               = lot.CountAvailable;
            this.priceCoinShiny      = lot.PriceCoinShiny;
            this.priceCoinPenny      = lot.PriceCoinPenny;
            this.priceCoinShinyRatio = 0;
            this.priceCoinPennyRatio = 0;
            this.protoItemType       = lot.ProtoItem.GetType().ToString()
                                       .Replace("AtomicTorch.CBND.CoreMod.Items.Generic.Item", "")
                                       .Replace("AtomicTorch.CBND.CoreMod.Items.Generic.", "");

            if (this.qty != 0)
            {
                this.priceCoinShinyRatio = Math.Round((double)lot.PriceCoinShiny / (double)this.qty, 3);
                this.priceCoinPennyRatio = Math.Round((double)lot.PriceCoinPenny / (double)this.qty, 3);
            }
        }
 private void ClientRemote_MarkAdded(TradingStationMark mark)
 {
     ClientTradingStationMarksList.Add(mark);
 }