コード例 #1
0
    public PlayerTailData TailPosition(int tailSegment, float timeStacker)
    {
        TailSegment tail = this.tail[tailSegment];
        Vector2     pos  = Vector2.Lerp(tail.lastPos, tail.pos, timeStacker);
        float       rad  = tail.rad;
        Vector2     dir;

        if (tailSegment == 0)
        {
            BodyChunk btm    = owner.bodyChunks[1];
            Vector2   btmPos = Vector2.Lerp(btm.lastPos, btm.pos, timeStacker);
            dir = (btmPos - pos).normalized;
        }
        else
        {
            TailSegment lastTail    = this.tail[tailSegment - 1];
            Vector2     lastTailPos = Vector2.Lerp(lastTail.lastPos, lastTail.pos, timeStacker);
            dir = (lastTailPos - pos).normalized;
        }

        Vector2 perp     = Custom.RotateAroundOrigo(dir, 80);
        Vector2 outerPos = pos + rad * perp;

        perp = Custom.RotateAroundOrigo(dir, -80);
        Vector2 innerPos = pos + rad * perp;

        perp = Custom.RotateAroundOrigo(dir, 90);

        return(new PlayerTailData(pos, outerPos, innerPos, dir, perp, rad));
    }
コード例 #2
0
 public virtual void Launch(Creature thrownBy, Vector2 thrownPos, Vector2?firstFrameTraceFromPos, Vector2 throwDir, float frc, bool eu)
 {
     this.thrownBy  = thrownBy;
     this.thrownPos = thrownPos;
     this.throwDir  = new IntVector2((int)(throwDir.x * 2), (int)(throwDir.y * 2));
     this.firstFrameTraceFromPos = firstFrameTraceFromPos;
     changeDirCounter            = 3;
     ChangeOverlap(true);
     base.firstChunk.MoveFromOutsideMyUpdate(eu, thrownPos);
     if (throwDir.x != 0)
     {
         base.firstChunk.vel.y = thrownBy.mainBodyChunk.vel.y * 0.5f;
         base.firstChunk.vel.x = thrownBy.mainBodyChunk.vel.x * 0.2f;
         BodyChunk firstChunk = base.firstChunk;
         firstChunk.vel.x = firstChunk.vel.x + (float)throwDir.x * 40f * frc;
         BodyChunk firstChunk2 = base.firstChunk;
         firstChunk2.vel.y = firstChunk2.vel.y + (float)throwDir.y * 40f * frc;
     }
     else
     {
         if (throwDir.y == 0)
         {
             ChangeMode(Mode.Free);
             return;
         }
         firstChunk.vel.x = thrownBy.mainBodyChunk.vel.x * 0.5f;
         firstChunk.vel.y = (float)throwDir.y * 40f * frc;
     }
     ChangeMode(Mode.Thrown);
     setRotation   = new Vector2?(throwDir);
     rotationSpeed = 0f;
     meleeHitChunk = null;
 }
コード例 #3
0
 public bool NetHit(PhysicalObject hit, BodyChunk chunk)
 {
     if (hit == null)
     {
         return(false);
     }
     if (this.thrownBy != null && this.thrownBy is Scavenger && (this.thrownBy as Scavenger).AI != null)
     {
         (this.thrownBy as Scavenger).AI.HitAnObjectWithWeapon(this, hit);
     }
     this.vibrate = 20;
     this.ChangeMode(Weapon.Mode.Free);
     if (hit is Creature)
     {
         (hit as Creature).Violence(base.firstChunk, new Vector2?(base.firstChunk.vel * base.firstChunk.mass), chunk, null, Creature.DamageType.Blunt, 0.01f, 45f);
     }
     else if (chunk != null)
     {
         chunk.vel += base.firstChunk.vel * base.firstChunk.mass / chunk.mass;
     }
     this.firstChunk.vel = this.firstChunk.vel * -0.5f + Custom.DegToVec(UnityEngine.Random.value * 360f) * Mathf.Lerp(0.1f, 0.4f, UnityEngine.Random.value) * this.firstChunk.vel.magnitude;
     this.room.PlaySound(SoundID.Rock_Hit_Creature, base.firstChunk);
     if (chunk != null)
     {
         this.room.AddObject(new ExplosionSpikes(this.room, chunk.pos, 5, 2f, 4f, 4.5f, 30f, new Color(1f, 1f, 1f, 0.5f)));
     }
     this.SetRandomSpin();
     return(true);
 }
コード例 #4
0
 // Token: 0x060018D6 RID: 6358 RVA: 0x0013EB70 File Offset: 0x0013CD70
 public override void Update(bool eu)
 {
     base.Update(eu);
     if (room.game.devToolsActive && Input.GetKey("b"))
     {
         firstChunk.vel += Custom.DirVec(firstChunk.pos, Input.mousePosition) * 3f;
     }
     lastRotation = rotation;
     if (grabbedBy.Count > 0)
     {
         rotation   = Custom.PerpendicularVector(Custom.DirVec(firstChunk.pos, grabbedBy[0].grabber.mainBodyChunk.pos));
         rotation.y = Mathf.Abs(rotation.y);
     }
     if (setRotation != null)
     {
         rotation    = setRotation.Value;
         setRotation = null;
     }
     if (base.firstChunk.ContactPoint.y < 0)
     {
         rotation = (rotation - Custom.PerpendicularVector(rotation) * 0.1f * base.firstChunk.vel.x).normalized;
         BodyChunk firstChunk = base.firstChunk;
         firstChunk.vel.x = firstChunk.vel.x * 0.8f;
     }
     if (Submersion > 0.5f && room.abstractRoom.creatures.Count > 0 && grabbedBy.Count == 0)
     {
         AbstractCreature abstractCreature = room.abstractRoom.creatures[UnityEngine.Random.Range(0, room.abstractRoom.creatures.Count)];
         if (abstractCreature.creatureTemplate.type == CreatureTemplate.Type.JetFish && abstractCreature.realizedCreature != null && !abstractCreature.realizedCreature.dead && (abstractCreature.realizedCreature as JetFish).AI.goToFood == null && (abstractCreature.realizedCreature as JetFish).AI.WantToEatObject(this))
         {
             (abstractCreature.realizedCreature as JetFish).AI.goToFood = this;
         }
     }
 }
コード例 #5
0
    public LightWorm(AbstractCreature abstractCreature, World world) : base(abstractCreature, world)
    {
        bodyChunks    = new BodyChunk[2];
        bodyChunks[0] = new BodyChunk(this, 0, new Vector2(0f, 0f), 8f, 0.05f);
        bodyChunks[1] = new BodyChunk(this, 0, new Vector2(0f, 0f), 8f, 0.05f);
        bodyChunks[0].rotationChunk      = bodyChunks[1];
        bodyChunks[1].collideWithTerrain = false;
        bodyChunkConnections             = new PhysicalObject.BodyChunkConnection[0];

        tentacle         = new Tentacle(this, bodyChunks[1], 400f * bodySize);
        tentacle.tProps  = new Tentacle.TentacleProps(false, false, true, 0.5f, 0f, 1.4f, 0f, 0f, 1.2f, 10f, 0.25f, 5f, 15, 60, 12, 0);
        tentacle.tChunks = new Tentacle.TentacleChunk[(int)(15f * Mathf.Lerp(bodySize, 1f, 0.5f))];
        for (int i = 0; i < tentacle.tChunks.Length; i++)
        {
            tentacle.tChunks[i] = new Tentacle.TentacleChunk(tentacle, i, (float)(i + 1) / (float)tentacle.tChunks.Length, 2f * Mathf.Lerp(bodySize, 1f, 0.5f));
        }
        tentacle.stretchAndSqueeze = 0.1f;

        GoThroughFloors = true;
        airFriction     = 0.99f;
        gravity         = 0.9f;
        bounce          = 0.1f;
        surfaceFriction = 0.47f;
        collisionLayer  = 1;
        waterFriction   = 0.92f;
        buoyancy        = 0.95f;
        extended        = 1f;
        retractSpeed    = 1f;
        lastExtended    = true;
    }
コード例 #6
0
 public void ctor(AbstractPhysicalObject abstractPhysicalObject, Room room)
 {
     orig_ctor(abstractPhysicalObject, room);
     if (ID == OracleID.SS)
     {
         this.oracleBehavior = new FPOracleBehaviorHasMark(this);
     }
     else
     {
         health     = 1f;
         bodyChunks = new BodyChunk[2];
         for (int i = 0; i < bodyChunks.Length; i++)
         {
             bodyChunks[i] = new BodyChunk(this, i, (ID != OracleID.SS) ? new Vector2(1585f + 5f * (float)i, 148f - 5f * (float)i) : new Vector2(350f, 350f), 6f, 0.5f);
         }
         bodyChunkConnections    = new PhysicalObject.BodyChunkConnection[1];
         bodyChunkConnections[0] = new PhysicalObject.BodyChunkConnection(bodyChunks[0], bodyChunks[1], 9f, BodyChunkConnection.Type.Normal, 1f, 0.5f);
         mySwarmers      = new System.Collections.Generic.List <OracleSwarmer>();
         airFriction     = 0.99f;
         gravity         = 0f;
         bounce          = 0.1f;
         surfaceFriction = 0.17f;
         collisionLayer  = 1;
         waterFriction   = 0.92f;
         buoyancy        = 0.95f;
         //this.moonmarbles = new List<MoonPearl>();
         //this.SetUpMoonMarbles();
         moonmarbles = new List <MoonPearl>();
         SetUpMoonMarbles();
         oracleBehavior = new LMOracleBehaviorHasMark(this);
         arm            = new patch_Oracle.OracleArm(this);
         room.gravity   = 0f;
     }
 }
コード例 #7
0
    public static void PutInInventory(Player player)
    {
        if (player.grasps[0] == null)
        {
            return;
        }

        List <AbstractPhysicalObject> content = new List <AbstractPhysicalObject>();

        foreach (AbstractPhysicalObject apo in Inventories[player.playerState.playerNumber])
        {
            content.Add(apo);
        }
        content.Add(player.grasps[0].grabbed.abstractPhysicalObject);
        Inventories.Remove(player.playerState.playerNumber);
        Inventories.Add(player.playerState.playerNumber, content);

        player.ReleaseGrasp(0);
        Inventories[player.playerState.playerNumber][Inventories[player.playerState.playerNumber].Count - 1].realizedObject.RemoveFromRoom();
        Inventories[player.playerState.playerNumber][Inventories[player.playerState.playerNumber].Count - 1].Abstractize(player.abstractCreature.pos);
        Inventories[player.playerState.playerNumber][Inventories[player.playerState.playerNumber].Count - 1].Room.RemoveEntity(Inventories[player.playerState.playerNumber][Inventories[player.playerState.playerNumber].Count - 1]);
        BodyChunk mainBodyChunk = player.mainBodyChunk;

        mainBodyChunk.vel.y = mainBodyChunk.vel.y + 2f;
        player.room.PlaySound(SoundID.Slugcat_Swallow_Item, player.mainBodyChunk);
    }
コード例 #8
0
 public override bool SpearStick(Weapon source, float dmg, BodyChunk chunk, PhysicalObject.Appendage.Pos onAppendagePos, Vector2 direction)
 {
     if (parry > 0f)
     {
         return(false);
     }
     return(true);
 }
コード例 #9
0
 private static void Lizard_Bite(On.Lizard.orig_Bite orig, Lizard self, BodyChunk chunk)
 {
     //Create small emitter when a Lizard bites are creature
     orig.Invoke(self, chunk);
     if (chunk != null && chunk.owner is Creature)
     {
         self.room.AddObject(new BloodEmitter(null, chunk, UnityEngine.Random.Range(1f, 5f), 0.08f));
     }
 }
コード例 #10
0
 public GenericBodyPart(GraphicsModule ow, float rd, float sfFric, float aFric, BodyChunk con)
     : base(ow)
 {
     rad         = rd;
     connection  = con;
     surfaceFric = sfFric;
     airFric     = aFric;
     Reset(con.pos);
 }
コード例 #11
0
 public static void Write(BodyChunk bodyChunk, ref BinaryWriter writer)
 {
     //IntVector2NHandler.Write(bodyChunk.ContactPoint, ref writer);
     //IntVector2NHandler.Write(bodyChunk.lastContactPoint, ref writer);
     //Vector2Handler.Write(bodyChunk.lastLastPos, ref writer);
     //Vector2Handler.Write(bodyChunk.lastPos, ref writer);
     Vector2Handler.Write(bodyChunk.pos, ref writer);
     Vector2Handler.Write(bodyChunk.vel, ref writer);
 }
コード例 #12
0
    private void Strike()
    {
        int num = UnityEngine.Random.Range(0, this.room.TileWidth);

        if (this.room.GetTile(num, this.room.TileHeight - 1).Solid)
        {
            return;
        }
        int num2 = this.room.roomRain.rainReach[num];

        if (num2 >= this.room.TileHeight)
        {
            return;
        }
        if (num2 == 0)
        {
            num2 = -10;
        }
        this.pos         = this.room.MiddleOfTile(num, num2) + new Vector2(Mathf.Lerp(-10f, 10f, UnityEngine.Random.value), 10f);
        this.skyPos      = this.room.MiddleOfTile(num, num2 + this.room.TileHeight + 50) + new Vector2(Mathf.Lerp(-30f, 30f, UnityEngine.Random.value) - 30f * this.roomRain.globalRain.rainDirection, 0f);
        this.falling     = 0f;
        this.lastFalling = 0f;
        this.moveTip     = true;
        this.fallSpeed   = 1f / Mathf.Lerp(0.2f, 1.8f, UnityEngine.Random.value);
        this.delay       = UnityEngine.Random.Range(0, 60 - (int)(this.roomRain.globalRain.bulletRainDensity * 60f));
        SharedPhysics.CollisionResult collisionResult = new SharedPhysics.CollisionResult();
        if (roomRain.room.roomSettings.RainIntensity != 0.01086957f)
        {
            collisionResult = SharedPhysics.TraceProjectileAgainstBodyChunks(null, this.room, this.skyPos, ref this.pos, 0.5f, 1, null, false);
        }
        if (this.room.water && this.room.PointSubmerged(this.pos))
        {
            this.pos.y = this.room.FloatWaterLevel(this.pos.x) - 30f;
            this.room.waterObject.WaterfallHitSurface(this.pos.x, this.pos.x, 1f);
            this.room.PlaySound(SoundID.Small_Object_Into_Water_Fast, this.pos);
        }
        else
        {
            this.room.PlaySound(SoundID.Bullet_Drip_Strike, this.pos);
        }

        if (roomRain.room.roomSettings.RainIntensity != 0.01086957f)
        {
            if (collisionResult.chunk != null)
            {
                this.pos = collisionResult.collisionPoint;
                BodyChunk chunk = collisionResult.chunk;
                chunk.vel.y = chunk.vel.y - 2f / collisionResult.chunk.mass;
                if (collisionResult.chunk.owner is Creature)
                {
                    (collisionResult.chunk.owner as Creature).Stun(UnityEngine.Random.Range(0, 4));
                }
            }
        }
    }
コード例 #13
0
        public static BodyChunk Read(BodyChunk bodyChunk, ref BinaryReader reader)
        {
            //(bodyChunk as Patches.patch_BodyChunk).Sync(IntVector2Handler.Read(ref reader));
            //bodyChunk.lastContactPoint = IntVector2Handler.Read(ref reader);

            //bodyChunk.lastLastPos = Vector2Handler.Read(ref reader);
            //bodyChunk.lastPos = Vector2Handler.Read(ref reader);
            bodyChunk.pos = Vector2Handler.Read(ref reader);
            bodyChunk.vel = Vector2Handler.Read(ref reader);
            return(bodyChunk);
        }
コード例 #14
0
        public BodyChunkConnection.Type type; //类型

        public BodyChunkConnection(BodyChunk chunk1, BodyChunk chunk2, float distance, PhysicalObject.BodyChunkConnection.Type type, float elasticity, float weightSymmetry)
        {
            this.chunk1          = chunk1;
            this.chunk2          = chunk2;
            this.distance        = distance;
            this.type            = type;
            this.elasticity      = elasticity;
            this.weightSymmetry  = weightSymmetry != -1.0 ? weightSymmetry : chunk2.mass / (chunk1.mass + chunk2.mass);
            this.active          = true;
            chunk1.rotationChunk = chunk2;
            chunk2.rotationChunk = chunk1;
        }
コード例 #15
0
        /*
         * public void PlayerKilled(ulong playerDead)
         * {
         *  MonklandSteamManager.DataPacket packet = MonklandSteamManager.instance.GetNewPacket(CHANNEL, UtilityHandler);
         *  BinaryWriter writer = MonklandSteamManager.instance.GetWriterForPacket(packet);
         *
         *  //Write message type
         *  writer.Write((byte)UtilMessageType.PlayerDead);
         *  writer.Write(playerDead);
         *
         *  MonklandSteamManager.instance.FinalizeWriterToPacket(writer, packet);
         *  MonklandSteamManager.instance.SendPacketToAll(packet, false, EP2PSend.k_EP2PSendReliable);
         *
         *  Debug.Log($"Writing packet: {packet.data}");
         * }
         */

        public void SendViolence(Creature self, BodyChunk source, Creature.DamageType type, float damage)
        {
            /*
             * Violence packet
             * packetType
             * damageType
             * sourceType (player/scav/lizard)
             * source ID
             */

            if (self == null || AbstractPhysicalObjectHK.GetField(self.abstractPhysicalObject).networkObject)
            {
                return;
            }

            // Source ID field
            MonklandSteamManager.DataPacket packet = MonklandSteamManager.instance.GetNewPacket(CHANNEL, UtilityHandler);
            BinaryWriter writer = MonklandSteamManager.instance.GetWriterForPacket(packet);

            // SourceTemplate
            byte sourceTemplate = byte.MaxValue - 1;

            try
            {
                sourceTemplate = (byte)(source.owner.abstractPhysicalObject as AbstractCreature).creatureTemplate.TopAncestor().type;
                //sourceTemplate = (byte)((source.owner as Creature).abstractCreature.creatureTemplate.type);
            }
            catch (Exception e) { Debug.Log("Error getting source type " + e.Message); }

            // SourceID
            ulong sourceID = 0;

            try
            {
                sourceID = (AbstractPhysicalObjectHK.GetField(source.owner.abstractPhysicalObject).owner);
            }
            catch { } //(Exception e) {/*Debug.Log()*/}

            // Message type
            writer.Write((byte)UtilMessageType.PlayerViolence);
            // Damage type
            writer.Write((byte)type);
            // Damage
            writer.Write((bool)(damage >= 1f));
            // Source Template
            writer.Write(sourceTemplate);
            // Source ID
            writer.Write(sourceID);

            MonklandSteamManager.Log($"[GameMNG] Sending Player Violence: Type {type}, damage {damage} Source Template {(CreatureTemplate.Type)sourceTemplate}, Source ID {sourceID}");
            MonklandSteamManager.instance.FinalizeWriterToPacket(writer, packet);
            MonklandSteamManager.instance.SendPacketToAll(packet, false, EP2PSend.k_EP2PSendReliable);
        }
コード例 #16
0
    //STRENGTH

    private static void Player_ThrownSpear(On.Player.orig_ThrownSpear orig, Player self, Spear spear)
    {
        spear.spearDamageBonus = 0.25f + ((self.playerState.foodInStomach / (KarmaAppetite.FOOD_POTENTIAL / 10)) * ((self.Karma >= 9) ? 1f : 0.5f));
        BodyChunk firstChunk2 = spear.firstChunk;
        float     speedBoost  = 0.73f + (self.playerState.foodInStomach / 10);

        if (speedBoost < 1f && self.playerState.foodInStomach > 0)
        {
            speedBoost = 1f;
        }
        firstChunk2.vel.x = firstChunk2.vel.x * speedBoost;
    }
コード例 #17
0
        public static BodyChunk Read(ref BinaryReader reader)
        {
            BodyChunk bodyChunk = new BodyChunk(null, 0, new Vector2(0f, 0f), 1f, 1f);

            //(bodyChunk as Patches.patch_BodyChunk).Sync(IntVector2Handler.Read(ref reader));
            //bodyChunk.lastContactPoint = IntVector2Handler.Read(ref reader);

            //bodyChunk.lastLastPos = Vector2Handler.Read(ref reader);
            //bodyChunk.lastPos = Vector2Handler.Read(ref reader);
            bodyChunk.pos = Vector2Handler.Read(ref reader);
            bodyChunk.vel = Vector2Handler.Read(ref reader);
            return(bodyChunk);
        }
コード例 #18
0
 public override void Violence(BodyChunk source, Vector2?directionAndMomentum, BodyChunk hitChunk, Appendage.Pos hitAppendage, DamageType type, float damage, float stunBonus)
 {
     if (type == DamageType.Stab && parry > 0f)
     {
         int num3 = (int)Math.Min(UnityEngine.Random.value + 10f, 25f);
         for (int i = 0; i < num3; i++)
         {
             room.AddObject(new Spark(source.pos + Custom.DegToVec(UnityEngine.Random.value * 360f) * 5f * UnityEngine.Random.value, source.vel * -0.1f + Custom.DegToVec(UnityEngine.Random.value * 360f) * Mathf.Lerp(0.2f, 0.4f, UnityEngine.Random.value) * source.vel.magnitude, new Color(1f, 1f, 1f), graphicsModule as LizardGraphics, 10, 170));
         }
         return;
     }
     base.Violence(source, directionAndMomentum, hitChunk, hitAppendage, type, damage, stunBonus);
 }
コード例 #19
0
 // Token: 0x060018D4 RID: 6356 RVA: 0x0013EABC File Offset: 0x0013CCBC
 public TreeFruit(AbstractPhysicalObject abstractPhysicalObject) : base(abstractPhysicalObject)
 {
     bites                = 2;
     bodyChunks           = new BodyChunk[1];
     bodyChunks[0]        = new BodyChunk(this, 0, new Vector2(0f, 0f), 8f, 0.2f);
     bodyChunkConnections = new PhysicalObject.BodyChunkConnection[0];
     airFriction          = 0.999f;
     gravity              = 0.9f;
     bounce               = 0.2f;
     surfaceFriction      = 0.7f;
     collisionLayer       = 1;
     waterFriction        = 0.95f;
     buoyancy             = 1.1f;
 }
コード例 #20
0
        public ChunkLabel(BodyChunk chunk, int index, Room room)
        {
            this.chunk    = chunk;
            startRoomName = room.abstractRoom.name;

            // set label text properties
            label = new FLabel("DisplayFont", index.ToString())
            {
                color     = Color.white,
                isVisible = TaggerMod.ChunkTagsVisible,
                anchorX   = 0.5f,
                scale     = 0.7f
            };
        }
コード例 #21
0
 public DaddyTentacle(DaddyLongLegs daddy, BodyChunk chunk, float length, int tentacleNumber, Vector2 tentacleDir)
     : base(daddy, chunk, length)
 {
     //触手索引 和 方向
     this.tentacleNumber = tentacleNumber;
     this.tentacleDir    = tentacleDir;
     //触手属性
     this.tProps = new Tentacle.TentacleProps(false, true, false, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 3.2f, 10f, 0.25f, 5f, 15, 60, 12, 20);
     //触手Chunk
     this.tChunks = new Tentacle.TentacleChunk[(int)(length / 40.0)];
     for (int index = 0; index < this.tChunks.Length; ++index)
     {
         this.tChunks[index] = new Tentacle.TentacleChunk(this, index, (index + 1) / (float)this.tChunks.Length, 3f);
     }
 }
コード例 #22
0
 public WalkerBeastTentacle(WalkerBeast walkerBeast, BodyChunk chunk, float length, int tentacleNumber) : base(walkerBeast, chunk, length)
 {
     setGrabDelay        = 8;
     this.tentacleNumber = tentacleNumber;
     tProps  = new Tentacle.TentacleProps(false, false, true, 0.5f, 0f, 0.6f, 0.8f, 1.04f, 1.2f, 10f, 1f, 5f, 15, 60, 12, 0);
     tChunks = new Tentacle.TentacleChunk[4];
     for (int i = 0; i < tChunks.Length; i++)
     {
         tChunks[i] = new Tentacle.TentacleChunk(this, i, (float)(i + 1) / (float)tChunks.Length, 4f);
     }
     side              = ((tentacleNumber % 2 != 0) ? 1 : 0);
     pair              = ((tentacleNumber >= 2) ? 1 : 0);
     tentacleDir       = Custom.DegToVec(45f + 90f * (float)tentacleNumber);
     stretchAndSqueeze = 0.1f;
     debugViz          = false;
 }
コード例 #23
0
ファイル: BattleRoomRain.cs プロジェクト: Garrakx/Monkland
        // Token: 0x06000E49 RID: 3657 RVA: 0x0009747C File Offset: 0x0009567C
        public void CreatureSmashedInGround(Creature crit, float speed)
        {
            if (speed < 2.5f)
            {
                return;
            }
            float      from         = this.InsidePushAround;
            BodyChunk  bodyChunk    = crit.bodyChunks[Random.Range(0, crit.bodyChunks.Length)];
            IntVector2 tilePosition = this.room.GetTilePosition(bodyChunk.pos + new Vector2(Mathf.Lerp(-bodyChunk.rad, bodyChunk.rad, Random.value), Mathf.Lerp(-bodyChunk.rad, bodyChunk.rad, Random.value)));

            if (this.rainReach[Custom.IntClamp(tilePosition.x, 0, this.room.TileWidth - 1)] < tilePosition.y)
            {
                from = Mathf.Max(this.OutsidePushAround, this.InsidePushAround);
            }
            crit.rainDeath += Mathf.InverseLerp(-2.5f, -15f, speed) * Mathf.Lerp(from, 1f, 0.5f) * 0.65f / (float)bodyChunk.owner.bodyChunks.Length;
        }
コード例 #24
0
 private void Swim(float speedFac)
 {
     if ((this.room.aimap.getAItile(base.bodyChunks[2].pos).narrowSpace || this.room.GetTile(base.bodyChunks[2].pos).Terrain == Room.Tile.TerrainType.ShortcutEntrance) && this.room.GetTile(base.bodyChunks[2].pos + Custom.DirVec(base.bodyChunks[1].pos, base.mainBodyChunk.pos) * 20f).Terrain != Room.Tile.TerrainType.Air)
     {
         MovementConnection movementConnection = (this.AI.pathFinder as FishPather).FollowPath(this.room.GetWorldCoordinate(base.mainBodyChunk.pos), true);
         bool flag = false;
         if (movementConnection == null)
         {
             flag = true;
             movementConnection = (this.AI.pathFinder as FishPather).FollowPath(this.room.GetWorldCoordinate(base.bodyChunks[1].pos), true);
         }
         if (movementConnection != null && movementConnection.destinationCoord.TileDefined)
         {
             base.mainBodyChunk.vel += Custom.DirVec(base.bodyChunks[(!flag) ? 0 : 1].pos, this.room.MiddleOfTile(movementConnection.DestTile)) * 1.8f;
             base.bodyChunks[1].vel += Custom.RNV() * 2f * UnityEngine.Random.value + Custom.DirVec(base.mainBodyChunk.pos, base.bodyChunks[1].pos) * UnityEngine.Random.value;
         }
         base.mainBodyChunk.terrainSqueeze = 0.1f;
         base.bodyChunks[1].terrainSqueeze = 0.1f;
         return;
     }
     this.jetWater           = Mathf.Clamp(this.jetWater + Mathf.Lerp(-0.04f, 0.0333333351f, Mathf.Pow(base.bodyChunks[1].submersion, 0.2f)), 0f, 1f);
     base.mainBodyChunk.vel += Custom.DirVec(base.bodyChunks[1].pos, base.mainBodyChunk.pos) * 1.4f * (1f - Mathf.Pow(base.bodyChunks[1].submersion, 0.2f)) * Mathf.InverseLerp(0f, 0.2f, this.jetWater) * speedFac;
     this.jetActive          = Mathf.Lerp(this.jetActive, (1f - Mathf.Pow(base.bodyChunks[1].submersion, 0.2f)) * Mathf.InverseLerp(0f, 0.2f, this.jetWater), 0.3f);
     this.swimSpeed          = Mathf.Lerp(Mathf.Lerp(1.8f, 3.2f + 6f * this.diveSpeed, this.turnSpeed) * (1f + this.surfSpeed * 0.5f), 1.4f, this.slowDownForPrecision) * ((this.grabbedBy.Count != 0) ? 1f : 0.85f);
     base.mainBodyChunk.vel += Custom.DirVec(base.bodyChunks[1].pos, base.mainBodyChunk.pos) * this.swimSpeed * Mathf.Pow(base.bodyChunks[1].submersion, 0.2f) * speedFac;
     base.bodyChunks[1].vel *= Mathf.Lerp(1f, 0.8f, Mathf.Pow(base.bodyChunks[1].submersion, 0.2f));
     if (this.swimDir.magnitude > 0f)
     {
         this.swimDir = Vector3.Slerp(this.swimDir.normalized, Custom.RNV(), 0.2f);
     }
     else
     {
         this.swimDir = Vector3.Slerp(Custom.DirVec(base.bodyChunks[1].pos, base.bodyChunks[0].pos), Custom.RNV(), 0.3f);
     }
     base.mainBodyChunk.vel += this.swimDir * ((this.grabbedBy.Count != 0) ? 1f : 0.7f) * 2.5f * speedFac;
     base.bodyChunks[1].vel -= this.swimDir * ((this.grabbedBy.Count != 0) ? 1f : 0.7f) * 2.5f * speedFac;
     if (base.mainBodyChunk.submersion < base.bodyChunks[1].submersion && this.swimDir.y > 0f)
     {
         BodyChunk mainBodyChunk = base.mainBodyChunk;
         mainBodyChunk.vel.y = mainBodyChunk.vel.y + 4f * base.bodyChunks[1].submersion;
     }
     this.swimDir *= 0f;
 }
コード例 #25
0
 public LargePiston(AbstractPhysicalObject abstractPhysicalObject) : base(abstractPhysicalObject)
 {
     bodyChunks           = new BodyChunk[1];
     bodyChunks[0]        = new BodyChunk(this, 0, new Vector2(0f, 0f), 30f, 14f);
     bodyChunkConnections = new BodyChunkConnection[0];
     airFriction          = 0.9f;
     gravity         = 0f;
     bounce          = 0f;
     surfaceFriction = 9.9f;
     collisionLayer  = 1;
     deathmode       = (abstractPhysicalObject as AbstractLargePiston).deathmode;
     deathtop        = (abstractPhysicalObject as AbstractLargePiston).deathtop;
     waterFriction   = 0.1f;
     buoyancy        = 0f;
     bodyChunks[0].collideWithObjects = true;
     bodyChunks[0].collideWithTerrain = false;
     bodyChunks[0].collideWithSlopes  = false;
     offset = UnityEngine.Random.Range(-1f, 1f);
 }
コード例 #26
0
        public static void Read(PhysicalObject physicalObject, ref BinaryReader reader)
        {
            AbstractPhysicalObjectHandler.Read(physicalObject.abstractPhysicalObject, ref reader);
            //int numberOfAppendages = reader.ReadInt32();
            //if (physicalObject.appendages.Count < numberOfAppendages)
            //{
            //    physicalObject.appendages = new List<PhysicalObject.Appendage>();
            //}
            //for (int a = 0; a < numberOfAppendages; a++)
            //{
            //    physicalObject.appendages[a] = AppendageHandler.Read(physicalObject.appendages[a], ref reader);
            //}

            int numberOfChunks = reader.ReadInt32();

            BodyChunk[] chunks = physicalObject.bodyChunks;

            if (physicalObject.bodyChunks.Length < numberOfChunks)
            {
                chunks = new BodyChunk[numberOfChunks];
            }
            for (int a = 0; a < numberOfChunks; a++)
            {
                chunks[a] = BodyChunkHandler.Read(chunks[a], ref reader);
            }

            SyncPhysicalObject(physicalObject, chunks);

            int numberOFConnections = reader.ReadInt32();

            if (physicalObject.bodyChunkConnections.Length < numberOFConnections)
            {
                physicalObject.bodyChunkConnections = new PhysicalObject.BodyChunkConnection[numberOFConnections];
            }
            for (int a = 0; a < numberOFConnections; a++)
            {
                physicalObject.bodyChunkConnections[a] = BodyChunkConnectionHandler.Read(physicalObject.bodyChunkConnections[a], ref reader);
            }

            physicalObject.bounce            = reader.ReadSingle();
            physicalObject.canBeHitByWeapons = reader.ReadBoolean();
        }
コード例 #27
0
    public void SwallowObject(int grasp)
    {
        if (grasp < 0 || base.grasps[grasp] == null)
        {
            return;
        }
        if (this.room.game.session is StoryGameSession && (this.room.game.session as StoryGameSession).saveState.miscWorldSaveData.moonRevived)
        {
            this.pearlConversation.PlayerSwallowItem(base.grasps[grasp].grabbed);
        }
        this.objectInStomach = base.grasps[grasp].grabbed.abstractPhysicalObject;
        this.ReleaseGrasp(grasp);
        this.objectInStomach.realizedObject.RemoveFromRoom();
        this.objectInStomach.Abstractize(base.abstractCreature.pos);
        this.objectInStomach.Room.RemoveEntity(this.objectInStomach);
        BodyChunk mainBodyChunk = base.mainBodyChunk;

        mainBodyChunk.vel.y = mainBodyChunk.vel.y + 2f;
        this.room.PlaySound(SoundID.Slugcat_Swallow_Item, base.mainBodyChunk);
    }
コード例 #28
0
 public void VoidSeaTreatment(Player player, float swimSpeed)
 {
     if (player.room != this.room)
     {
         return;
     }
     (player as patch_Player).voidEnergy = true;
     (player as patch_Player).maxEnergy  = Custom.LerpMap(player.mainBodyChunk.pos.y, -1000f, -5000f, 1f, 0f);
     if (!(player as patch_Player).past22000 && player.mainBodyChunk.pos.y < -22000)
     {
         (player as patch_Player).past22000 = true;
     }
     else if (!(player as patch_Player).past25000 && player.mainBodyChunk.pos.y < -25000)
     {
         (player as patch_Player).past25000 = true;
     }
     if (this.deepDivePhase == VoidSeaScene.DeepDivePhase.EggScenario)
     {
         (player as patch_Player).past25000 = true;
     }
     for (int i = 0; i < player.bodyChunks.Length; i++)
     {
         player.bodyChunks[i].restrictInRoomRange = float.MaxValue;
         player.bodyChunks[i].vel *= Mathf.Lerp(swimSpeed, 1f, this.room.game.cameras[0].voidSeaGoldFilter);
         BodyChunk bodyChunk = player.bodyChunks[i];
         bodyChunk.vel.y = bodyChunk.vel.y - player.buoyancy;
         BodyChunk bodyChunk2 = player.bodyChunks[i];
         bodyChunk2.vel.y = bodyChunk2.vel.y + player.gravity;
     }
     player.airInLungs     = 1f;
     player.lungsExhausted = false;
     if (player.graphicsModule != null && (player.graphicsModule as PlayerGraphics).lightSource != null)
     {
         (player.graphicsModule as PlayerGraphics).lightSource.setAlpha = new float?(Custom.LerpMap(player.mainBodyChunk.pos.y, -2000f, -8000f, 1f, 0.2f) * (1f - this.eggProximity));
         (player.graphicsModule as PlayerGraphics).lightSource.setRad   = new float?(Custom.LerpMap(player.mainBodyChunk.pos.y, -2000f, -8000f, 300f, 200f) * (0.5f + 0.5f * (1f - this.eggProximity)));
     }
     if (this.deepDivePhase == VoidSeaScene.DeepDivePhase.EggScenario && UnityEngine.Random.value < 0.1f)
     {
         player.mainBodyChunk.vel += Custom.DirVec(player.mainBodyChunk.pos, this.theEgg.pos) * 0.02f * UnityEngine.Random.value;
     }
 }
コード例 #29
0
ファイル: patch_Spear.cs プロジェクト: Dracentis/Monkland
        public void NetThrown(Creature thrownBy, Vector2 thrownPos, Vector2?firstFrameTraceFromPos, IntVector2 throwDir, float frc)
        {
            //base.Thrown()
            this.thrownBy  = thrownBy;
            this.thrownPos = thrownPos;
            this.throwDir  = throwDir;
            this.firstFrameTraceFromPos = firstFrameTraceFromPos;
            this.changeDirCounter       = 3;
            this.ChangeOverlap(true);
            this.firstChunk.HardSetPosition(thrownPos);
            this.GoThroughFloors = false;
            if (throwDir.x != 0)
            {
                base.firstChunk.vel.y = thrownBy.mainBodyChunk.vel.y * 0.5f;
                base.firstChunk.vel.x = thrownBy.mainBodyChunk.vel.x * 0.2f;
                BodyChunk firstChunk = base.firstChunk;
                firstChunk.vel.x = firstChunk.vel.x + (float)throwDir.x * 40f * frc;
                BodyChunk firstChunk2 = base.firstChunk;
                firstChunk2.vel.y = firstChunk2.vel.y + ((!(this is Spear)) ? 3f : 1.5f);
            }
            else
            {
                if (throwDir.y == 0)
                {
                    this.ChangeMode(Weapon.Mode.Free);
                    return;
                }
                base.firstChunk.vel.x = thrownBy.mainBodyChunk.vel.x * 0.5f;
                base.firstChunk.vel.y = (float)throwDir.y * 40f * frc;
            }
            this.ChangeMode(Weapon.Mode.Thrown);
            this.setRotation   = new Vector2?(throwDir.ToVector2());
            this.rotationSpeed = 0f;
            this.meleeHitChunk = null;

            //Spear
            this.room.PlaySound(SoundID.Slugcat_Throw_Spear, base.firstChunk);
            this.alwaysStickInWalls = false;
        }
コード例 #30
0
ファイル: BloodEmitter.cs プロジェクト: LeeMoriya/Blood
 public BloodEmitter(Spear spear, BodyChunk chunk, float velocity, float bleedTime)
 {
     //Downpour support, washes away blood splatters if enabled
     this.currentTime      = Time.time;
     this.spear            = spear;
     this.chunk            = chunk;
     this.bleedTime        = bleedTime;
     this.initialBleedTime = bleedTime;
     this.maxVelocity      = velocity + (BloodMod.goreMultiplier * 3);
     //Default blood color
     this.creatureColor = new Color(0.5f, 0f, 0f);
     this.splatterColor = "Slugcat";
     //Individual blood colors
     if (this.chunk.owner is Creature)
     {
         //Get creature blood color from dictionary
         if (BloodMod.creatureColors.ContainsKey((this.chunk.owner as Creature).Template.type.ToString()))
         {
             this.creatureColor = BloodMod.creatureColors[(this.chunk.owner as Creature).Template.type.ToString()];
             this.splatterColor = (this.chunk.owner as Creature).Template.type.ToString();
         }
     }
 }