Ejemplo n.º 1
0
        /// <summary>
        /// Sends the received <see cref="ModPacket"/> to the desired <see cref="PacketHandler"/> based on data read from <paramref name="reader"/>.
        /// </summary>
        /// <param name="reader">The <see cref="BinaryReader"/> that reads the received <see cref="ModPacket"/>.</param>
        /// <param name="fromWho">The player that this packet is from.</param>
        internal void HandlePacket(BinaryReader reader, int fromWho)
        {
            byte packetClass = reader.ReadByte();

            switch (packetClass)
            {
            case OriState:
                oriPlayerHandler.HandlePacket(reader, fromWho);
                break;

            case AbilityState:
                abilityPacketHandler.HandlePacket(reader, fromWho);
                break;

            default:
                OriMod.Error("UnknownPacket", args: packetClass);
                break;
            }
        }
Ejemplo n.º 2
0
        internal override void Tick()
        {
            if (_placedSoulLink && _wasDead && !player.dead)
            {
                _wasDead = false;
                OnRespawn();
            }

            if (_placedSoulLink)
            {
                CheckValidPlacement(Center, out _obstructed);
                if (_obstructed)
                {
                    _placedSoulLink = false;
                    OriMod.Error("SoulLinkObstructed", log: false);
                }
            }
            if (CanUse && OriMod.soulLinkKey.Current)
            {
                if (OriMod.soulLinkKey.JustPressed)
                {
                    _anyBossAlive = OriUtils.IsAnyBossAlive();
                    if (_anyBossAlive)
                    {
                        OriMod.Error("SoulLinkBossActive", log: false);
                        return;
                    }
                }
                CheckValidPlacement(player.Center.ToTileCoordinates(), out bool tempObstructed, force: true);
                if (tempObstructed)
                {
                    if (!_wasObstructed)
                    {
                        OriMod.Error("SoulLinkCannotPlace", log: false);
                    }
                    _currentCharge -= UnchargeRate;
                    if (_currentCharge < 0)
                    {
                        _currentCharge = 0;
                    }
                }
                else
                {
                    _currentCharge += ChargeRate;
                    if (_currentCharge > 1)
                    {
                        player.statMana -= ManaCost;
                        _currentCharge   = 0;
                        SetState(State.Active);
                        _placedSoulLink = true;
                        Box.UpdateHitbox(player.Center);
                        SoulLinkLocation = Center;
                        oPlayer.Debug("Placed a Soul Link!");
                        PutOnCooldown(force: true);
                    }
                }
                _wasObstructed = tempObstructed;
            }
            else if (_currentCharge > 0)
            {
                _currentCharge -= UnchargeRate;
                if (_currentCharge < 0)
                {
                    _currentCharge = 0;
                }
            }
            if (_currentCharge > 0 && _currentCharge < 1)
            {
                Dust dust = Dust.NewDustDirect(player.Center, 12, 12, ModContent.DustType <SoulLinkChargeDust>(), newColor: Color.DeepSkyBlue);
                dust.customData = player;
                dust.position  += -Vector2.UnitY.RotatedBy(_currentCharge * 2 * Math.PI) * 56;
            }
            TickCooldown();
        }