Ejemplo n.º 1
0
 /// <summary>
 /// Clamps this <see cref="WorldCoordinate"/> between two other <see cref="WorldCoordinate"/> values.
 /// </summary>
 /// <param name="lower">The lower bound to clamp between.</param>
 /// <param name="upper">The upper bound to clamp between.</param>
 /// <returns>A new <see cref="WorldCoordinate"/>, clamped within the given bounds.</returns>
 public WorldCoordinate Clamp(WorldCoordinate lower, WorldCoordinate upper)
 {
     return((this < lower) ? lower : (this > upper) ? upper : this);
 }
 private void GeneratePopulation(bool fresh)
 {
     Debug.Log(string.Concat(new object[]
     {
         "Generate population for : ",
         this.world.region.name,
         " FRESH: ",
         fresh
     }));
     if (this.world.game.setupValues.proceedLineages > 0)
     {
         for (int i = 0; i < this.spawners.Count; i++)
         {
             if (this.spawners[i] is World.Lineage)
             {
                 for (int j = 0; j < this.world.game.setupValues.proceedLineages; j++)
                 {
                     (this.spawners[i] as World.Lineage).ChanceToProgress(this.world);
                 }
             }
         }
     }
     //----------------------------------------Error start
     for (int k = 0; k < this.spawners.Count; k++)
     {
         if (this.spawners[k] is World.SimpleSpawner)
         {
             World.SimpleSpawner simpleSpawner = this.spawners[k] as World.SimpleSpawner;
             int num;
             if (fresh || StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).quantified || !StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).saveCreature)
             {
                 num = simpleSpawner.amount;
             }
             else
             {
                 num = this.HowManyOfThisCritterShouldRespawn(simpleSpawner.SpawnerID, simpleSpawner.amount);
             }
             if (num > 0)
             {
                 AbstractRoom abstractRoom = this.world.GetAbstractRoom(simpleSpawner.den);
                 if (abstractRoom != null && simpleSpawner.den.abstractNode >= 0 && simpleSpawner.den.abstractNode < abstractRoom.nodes.Length && (abstractRoom.nodes[simpleSpawner.den.abstractNode].type == AbstractRoomNode.Type.Den || abstractRoom.nodes[simpleSpawner.den.abstractNode].type == AbstractRoomNode.Type.GarbageHoles))
                 {
                     if (StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType).quantified)
                     {
                         abstractRoom.AddQuantifiedCreature(simpleSpawner.den.abstractNode, simpleSpawner.creatureType, simpleSpawner.amount);
                     }
                     else
                     {
                         for (int l = 0; l < num; l++)
                         {
                             abstractRoom.MoveEntityToDen(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(simpleSpawner.creatureType), null, simpleSpawner.den, this.world.game.GetNewID(simpleSpawner.SpawnerID))
                             {
                                 spawnData = simpleSpawner.spawnDataString
                             });
                         }
                     }
                 }
             }
         }
         else if (this.spawners[k] is World.Lineage)
         {
             World.Lineage lineage = this.spawners[k] as World.Lineage;
             bool          flag    = fresh || this.ShouldThisCritterRespawn(lineage.SpawnerID);
             if (flag)
             {
                 AbstractRoom          abstractRoom2 = this.world.GetAbstractRoom(lineage.den);
                 CreatureTemplate.Type?type          = lineage.CurrentType((this.game.session as StoryGameSession).saveState);
                 if (type == null)
                 {
                     lineage.ChanceToProgress(this.world);
                 }
                 else if (abstractRoom2 != null && lineage.den.abstractNode >= 0 && lineage.den.abstractNode < abstractRoom2.nodes.Length && (abstractRoom2.nodes[lineage.den.abstractNode].type == AbstractRoomNode.Type.Den || abstractRoom2.nodes[lineage.den.abstractNode].type == AbstractRoomNode.Type.GarbageHoles))
                 {
                     abstractRoom2.MoveEntityToDen(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(type.Value), null, lineage.den, this.world.game.GetNewID(lineage.SpawnerID))
                     {
                         spawnData = lineage.CurrentSpawnData((this.game.session as StoryGameSession).saveState)
                     });
                 }
                 if (type == null)
                 {
                     (this.game.session as StoryGameSession).saveState.respawnCreatures.Add(lineage.SpawnerID);
                     Debug.Log("add NONE creature to respawns for lineage " + lineage.SpawnerID);
                 }
             }
         }
     }
     //--------------------Error end
     if (this.playerCharacter != 2 && !(this.game.session as StoryGameSession).saveState.guideOverseerDead && !(this.game.session as StoryGameSession).saveState.miscWorldSaveData.playerGuideState.angryWithPlayer && UnityEngine.Random.value < this.world.region.regionParams.playerGuideOverseerSpawnChance)
     {
         WorldCoordinate worldCoordinate = new WorldCoordinate(this.world.offScreenDen.index, -1, -1, 0);
         if (this.world.region.name == "SU")
         {
             worldCoordinate = new WorldCoordinate(this.world.GetAbstractRoom("SU_C04").index, 137, 17, 0);
         }
         AbstractCreature abstractCreature = new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer), null, worldCoordinate, new EntityID(-1, 5));
         if (this.world.GetAbstractRoom(worldCoordinate).offScreenDen)
         {
             this.world.GetAbstractRoom(worldCoordinate).entitiesInDens.Add(abstractCreature);
         }
         else
         {
             this.world.GetAbstractRoom(worldCoordinate).AddEntity(abstractCreature);
         }
         (abstractCreature.abstractAI as OverseerAbstractAI).SetAsPlayerGuide();
     }
     if (this.world.region.name == "UW" || UnityEngine.Random.value < this.world.region.regionParams.overseersSpawnChance * Mathf.InverseLerp(2f, 21f, (float)((this.game.session as StoryGameSession).saveState.cycleNumber + ((this.game.StoryCharacter != 2) ? 0 : 17))))
     {
         int num2 = UnityEngine.Random.Range(this.world.region.regionParams.overseersMin, this.world.region.regionParams.overseersMax);
         for (int m = 0; m < num2; m++)
         {
             this.world.offScreenDen.entitiesInDens.Add(new AbstractCreature(this.world, StaticWorld.GetCreatureTemplate(CreatureTemplate.Type.Overseer), null, new WorldCoordinate(this.world.offScreenDen.index, -1, -1, 0), this.game.GetNewID()));
         }
     }
 }
Ejemplo n.º 3
0
 public WarpCommandPacket()
 {
     Player      = String.Empty;
     Coordinates = new WorldCoordinate();
 }
 public extern void orig_ctor(World world, patch_CreatureTemplate creatureTemplate, patch_Creature realizedCreature, WorldCoordinate pos, EntityID ID);
    public void ctor(World world, patch_CreatureTemplate creatureTemplate, patch_Creature realizedCreature, WorldCoordinate pos, EntityID ID)
    {
        orig_ctor(world, creatureTemplate, realizedCreature, pos, ID);
        CreatureTemplate.Type type = creatureTemplate.TopAncestor().type;
        if (creatureTemplate.AI)
        {
            type = creatureTemplate.type;
            switch (type)
            {
            case CreatureTemplate.Type.Scavenger:
                abstractAI = new ScavengerAbstractAI(world, this);
                goto IL_2F4;

            case CreatureTemplate.Type.Overseer:
                abstractAI = new OverseerAbstractAI(world, this);
                goto IL_2F4;

            default:
                switch (type)
                {
                case CreatureTemplate.Type.Vulture:
                    break;

                default:
                    if (type != CreatureTemplate.Type.MirosBird)
                    {
                        abstractAI = new AbstractCreatureAI(world, this);
                        goto IL_2F4;
                    }
                    abstractAI = new MirosBirdAbstractAI(world, this);
                    goto IL_2F4;

                case CreatureTemplate.Type.CicadaA:
                case CreatureTemplate.Type.CicadaB:
                    abstractAI = new CicadaAbstractAI(world, this);
                    goto IL_2F4;

                case CreatureTemplate.Type.BigEel:
                    abstractAI = new BigEelAbstractAI(world, this);
                    goto IL_2F4;

                case CreatureTemplate.Type.Deer:
                    abstractAI = new DeerAbstractAI(world, this);
                    goto IL_2F4;

                case (CreatureTemplate.Type)patch_CreatureTemplate.Type.WalkerBeast:
                    abstractAI = new WalkerBeastAbstractAI(world, this);
                    goto IL_2F4;
                }
                break;

            case CreatureTemplate.Type.SmallNeedleWorm:
            case CreatureTemplate.Type.BigNeedleWorm:
                abstractAI = new NeedleWormAbstractAI(world, this);
                goto IL_2F4;

            case CreatureTemplate.Type.DropBug:
                abstractAI = new DropBugAbstractAI(world, this);
                goto IL_2F4;

            case CreatureTemplate.Type.KingVulture:
                break;
            }
            abstractAI = new VultureAbstractAI(world, this);
        }
IL_2F4:
        if (pos.abstractNode > -1 && pos.abstractNode < Room.nodes.Length && Room.nodes[pos.abstractNode].type == AbstractRoomNode.Type.Den && !pos.TileDefined)
        {
            if (Room.offScreenDen)
            {
                remainInDenCounter = 1;
            }
            else
            {
                remainInDenCounter = UnityEngine.Random.Range(100, 1000);
            }
            if (abstractAI != null)
            {
                abstractAI.denPosition = new WorldCoordinate?(pos);
            }
            spawnDen = pos;
        }
        if (creatureTemplate.type == CreatureTemplate.Type.TentaclePlant || creatureTemplate.type == CreatureTemplate.Type.PoleMimic)
        {
            remainInDenCounter = 0;
        }
    }
Ejemplo n.º 6
0
 public patch_AbstractCreature(World world, CreatureTemplate creatureTemplate, Creature realizedCreature, WorldCoordinate pos, EntityID ID) : base(world, creatureTemplate, realizedCreature, pos, ID)
 {
 }
Ejemplo n.º 7
0
 public void WriteWorldCoordinate(WorldCoordinate coordinate)
 {
     coordinate.WriteTo(this);
 }
Ejemplo n.º 8
0
 public extern void OriginalConstructor(World world, AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID);
Ejemplo n.º 9
0
 public void ctor_AbstractPhysicalObject(World world, AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID)
 {
     OriginalConstructor(world, type, realizedObject, pos, ID);
     if (ID.number != -1 && ID.number != 5 && ID.number != 0 && this.ID.number != 1 && this.ID.number != 2 && this.ID.number == 3)
     {
         while ((this.ID.number >= -1 && this.ID.number <= 15000))
         {
             this.ID.number = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
         }
     }
     if (ID.number == 0)
     {
         playerdist = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
     }
     if (MonklandSteamManager.isInGame)
     {
         owner = NetworkGameManager.playerID;
     }
 }
    public MovementConnection FollowPath(WorldCoordinate originPos, bool actuallyFollowingThisPath)
    {
        int             num        = int.MinValue;
        PathCost        costToGoal = new PathCost(0f, PathCost.Legality.Unallowed);
        WorldCoordinate dest       = originPos;

        if (!originPos.TileDefined && !originPos.NodeDefined)
        {
            return(null);
        }
        WorldCoordinate worldCoordinate = RestrictedOriginPos(originPos);

        if (actuallyFollowingThisPath && debugDrawer != null)
        {
            debugDrawer.Blink(worldCoordinate);
        }
        AItile aitile = realizedRoom.aimap.getAItile(worldCoordinate.x, worldCoordinate.y);

        PathFinder.PathingCell pathingCell = PathingCellAtWorldCoordinate(worldCoordinate);
        if (pathingCell != null)
        {
            if (!pathingCell.reachable || !pathingCell.possibleToGetBackFrom)
            {
                OutOfElement(worldCoordinate);
            }
            MovementConnection movementConnection = null;
            PathCost           b       = new PathCost(0f, PathCost.Legality.Unallowed);
            int num2                   = -acceptablePathAge;
            PathCost.Legality legality = PathCost.Legality.Unallowed;
            int   num3                 = -acceptablePathAge;
            float num4                 = float.MaxValue;
            int   num5                 = 0;
            for (; ;)
            {
                MovementConnection movementConnection2 = ConnectionAtCoordinate(true, worldCoordinate, num5);
                num5++;
                if (movementConnection2 == null)
                {
                    break;
                }
                if (movementConnection2.type == MovementConnection.MovementType.Standard && movementConnection2.StartTile.FloatDist(movementConnection2.DestTile) > 1f)
                {
                    //Debug.Log("WTF " + movementConnection2);
                }
                if (!movementConnection2.destinationCoord.TileDefined || Custom.InsideRect(movementConnection2.DestTile, coveredArea))
                {
                    PathFinder.PathingCell pathingCell2 = PathingCellAtWorldCoordinate(movementConnection2.destinationCoord);
                    PathCost pathCost = CheckConnectionCost(pathingCell, pathingCell2, movementConnection2, true);
                    if (!pathingCell2.possibleToGetBackFrom && !walkPastPointOfNoReturn)
                    {
                        pathCost.legality = PathCost.Legality.Unallowed;
                    }
                    PathCost pathCost2 = pathingCell2.costToGoal + pathCost;
                    if (movementConnection2.destinationCoord.TileDefined && destination.TileDefined && movementConnection2.destinationCoord.Tile == destination.Tile)
                    {
                        pathCost2.resistance = 0f;
                    }
                    else if (realizedRoom.IsPositionInsideBoundries(creature.pos.Tile) && ConnectionAlreadyFollowedSeveralTimes(movementConnection2))
                    {
                        pathCost += new PathCost(0f, PathCost.Legality.Unwanted);
                    }
                    if (movementConnection2.type == MovementConnection.MovementType.OutsideRoom && !(AI as WalkerBeastAI).AllowMovementBetweenRooms)
                    {
                        pathCost += new PathCost(0f, PathCost.Legality.Unallowed);
                    }
                    if (Input.GetKey("u") && actuallyFollowingThisPath)
                    {
                        Debug.Log("                     ");
                        Debug.Log(movementConnection2.startCoord);
                        CDebug.Log(movementConnection2.type.ToString(), movementConnection2.destinationCoord);
                        Debug.Log(string.Concat(new object[]
                        {
                            "conn: ",
                            pathCost.legality.ToString(),
                            " ",
                            pathCost.resistance
                        }));
                        Debug.Log(string.Concat(new object[]
                        {
                            "costToGoal: ",
                            pathingCell2.costToGoal.legality.ToString(),
                            " ",
                            pathingCell2.costToGoal.resistance
                        }));
                        Debug.Log(string.Concat(new object[]
                        {
                            "totCost: ",
                            pathCost2.legality.ToString(),
                            " ",
                            pathCost2.resistance
                        }));
                        Debug.Log("generation: " + pathingCell2.generation);
                        if (!pathingCell2.possibleToGetBackFrom && !walkPastPointOfNoReturn)
                        {
                            Debug.Log("PONOR");
                        }
                    }
                    if (pathingCell2.generation > num3)
                    {
                        num3 = pathingCell2.generation;
                        num4 = pathCost2.resistance;
                    }
                    else if (pathingCell2.generation == num3 && pathCost2.resistance < num4)
                    {
                        num4 = pathCost2.resistance;
                    }
                    if (pathCost.legality < legality)
                    {
                        movementConnection = movementConnection2;
                        legality           = pathCost.legality;
                        num2 = pathingCell2.generation;
                        b    = pathCost2;
                    }
                    else if (pathCost.legality == legality)
                    {
                        if (pathingCell2.generation > num2)
                        {
                            movementConnection = movementConnection2;
                            legality           = pathCost.legality;
                            num2 = pathingCell2.generation;
                            b    = pathCost2;
                        }
                        else if (pathingCell2.generation == num2 && pathCost2 <= b)
                        {
                            movementConnection = movementConnection2;
                            legality           = pathCost.legality;
                            num2 = pathingCell2.generation;
                            b    = pathCost2;
                        }
                    }
                }
            }
            if (Input.GetKey("u") && actuallyFollowingThisPath)
            {
                Debug.Log(worldCoordinate);
                CDebug.Log("chosen move: ", movementConnection);
            }
            if (legality <= PathCost.Legality.Unwanted)
            {
                if (actuallyFollowingThisPath)
                {
                    if (movementConnection != null && movementConnection.type == MovementConnection.MovementType.ShortCut && realizedRoom.shortcutData(movementConnection.StartTile).shortCutType == ShortcutData.Type.RoomExit)
                    {
                        LeavingRoom();
                    }
                    creatureFollowingGeneration = num2;
                }
                if (!actuallyFollowingThisPath || movementConnection == null || movementConnection.type != MovementConnection.MovementType.OutsideRoom || movementConnection.destinationCoord.TileDefined || walkerBeast.shortcutDelay >= 1)
                {
                    return(movementConnection);
                }
                int num6 = 30;
                if (!Custom.InsideRect(originPos.Tile, new IntRect(-num6, -num6, realizedRoom.TileWidth + num6, realizedRoom.TileHeight + num6)))
                {
                    foreach (WorldCoordinate worldCoordinate2 in world.sideAccessNodes)
                    {
                        PathFinder.PathingCell pathingCell3 = PathingCellAtWorldCoordinate(worldCoordinate2);
                        if (pathingCell3.generation > num)
                        {
                            num        = pathingCell3.generation;
                            costToGoal = pathingCell3.costToGoal;
                            dest       = worldCoordinate2;
                        }
                        else if (pathingCell3.generation == num && pathingCell3.costToGoal < costToGoal)
                        {
                            costToGoal = pathingCell3.costToGoal;
                            dest       = worldCoordinate2;
                        }
                        if (worldCoordinate2.CompareDisregardingTile(destination))
                        {
                            dest = worldCoordinate2;
                            break;
                        }
                    }
                    if (!dest.CompareDisregardingTile(movementConnection.destinationCoord))
                    {
                        walkerBeast.AccessSideSpace(movementConnection.destinationCoord, dest);
                        if (dest.room != creaturePos.room)
                        {
                            LeavingRoom();
                        }
                    }
                    return(null);
                }
                IntVector2 intVector = new IntVector2(0, 1);
                if (movementConnection.startCoord.x == 0)
                {
                    intVector = new IntVector2(-1, 0);
                }
                else if (movementConnection.startCoord.x == realizedRoom.TileWidth - 1)
                {
                    intVector = new IntVector2(1, 0);
                }
                else if (movementConnection.startCoord.y == 0)
                {
                    intVector = new IntVector2(0, -1);
                }
                return(new MovementConnection(MovementConnection.MovementType.Standard, originPos, new WorldCoordinate(originPos.room, originPos.x + intVector.x * 10, originPos.y + intVector.y * 10, originPos.abstractNode), 1));
            }
        }
        return(null);
    }
Ejemplo n.º 11
0
 public patch_AbstractPhysicalObject(World world, AbstractObjectType type, PhysicalObject realizedObject, WorldCoordinate pos, EntityID ID) : base(world, type, realizedObject, pos, ID)
 {
 }
 public override void DestinationHasChanged(WorldCoordinate oldDestination, WorldCoordinate newDestination)
 {
 }
Ejemplo n.º 13
0
        public void API_Move()
        {
            var newPos = new WorldCoordinate(room.name, localPoint + IntPoint.DirectionToIntPoint(direction));

            position = newPos;
        }
Ejemplo n.º 14
0
    // Token: 0x06001E6C RID: 7788 RVA: 0x001B2720 File Offset: 0x001B0920
    public override void Update()
    {
        this.focusCreature = null;
        base.Update();
        if (this.getAwayCounter > 0)
        {
            this.getAwayCounter--;
        }
        AIModule aimodule = base.utilityComparer.HighestUtilityModule();

        this.currentUtility = base.utilityComparer.HighestUtility();
        if (aimodule != null)
        {
            if (aimodule is ThreatTracker)
            {
                this.behavior = SeaDrakeAI.Behavior.Flee;
            }
            else if (aimodule is RainTracker)
            {
                this.behavior = SeaDrakeAI.Behavior.EscapeRain;
            }
            else if (aimodule is PreyTracker)
            {
                if (this.creature.realizedCreature != null && preyTracker.MostAttractivePrey.representedCreature.realizedCreature != null && !this.creature.realizedCreature.room.PointSubmerged(preyTracker.MostAttractivePrey.representedCreature.realizedCreature.mainBodyChunk.pos))
                {
                    this.behavior = SeaDrakeAI.Behavior.Idle;
                }
                this.behavior = SeaDrakeAI.Behavior.Hunt;
            }
            else if (aimodule is NoiseTracker)
            {
                this.behavior = SeaDrakeAI.Behavior.ExamineSound;
            }
            else if (aimodule is StuckTracker)
            {
                this.behavior = SeaDrakeAI.Behavior.GetUnstuck;
            }
        }
        if (this.currentUtility < 0.1f)
        {
            this.behavior = SeaDrakeAI.Behavior.Idle;
        }
        if (this.behavior != SeaDrakeAI.Behavior.Flee && this.fish.grasps[0] != null)
        {
            this.behavior = SeaDrakeAI.Behavior.ReturnPrey;
        }
        switch (this.behavior)
        {
        case SeaDrakeAI.Behavior.Idle:
            if (this.exploreCoordinate != null)
            {
                this.creature.abstractAI.SetDestination(this.exploreCoordinate.Value);
                if (Custom.ManhattanDistance(this.creature.pos, this.exploreCoordinate.Value) < 5 || (UnityEngine.Random.value < 0.0125f && base.pathFinder.DoneMappingAccessibility && this.fish.room.aimap.TileAccessibleToCreature(this.creature.pos.x, this.creature.pos.y, this.creature.creatureTemplate) && !base.pathFinder.CoordinateReachableAndGetbackable(this.exploreCoordinate.Value)))
                {
                    this.exploreCoordinate = null;
                }
            }
            else if (Custom.ManhattanDistance(this.creature.pos, base.pathFinder.GetDestination) < 5 || !base.pathFinder.CoordinateReachableAndGetbackable(base.pathFinder.GetDestination))
            {
                WorldCoordinate worldCoordinate = this.fish.room.GetWorldCoordinate(Custom.RestrictInRect(this.fish.mainBodyChunk.pos, new FloatRect(0f, 0f, this.fish.room.PixelWidth, this.fish.room.PixelHeight)) + Custom.RNV() * 200f);
                if (this.fish.room.IsPositionInsideBoundries(worldCoordinate.Tile) && base.pathFinder.CoordinateReachableAndGetbackable(worldCoordinate) && this.fish.room.VisualContact(this.creature.pos.Tile, worldCoordinate.Tile))
                {
                    this.creature.abstractAI.SetDestination(worldCoordinate);
                }
            }
            if (UnityEngine.Random.value < 1f / ((this.exploreCoordinate == null) ? 80f : 1600f))
            {
                WorldCoordinate worldCoordinate2 = new WorldCoordinate(this.fish.room.abstractRoom.index, UnityEngine.Random.Range(0, this.fish.room.TileWidth), UnityEngine.Random.Range(0, this.fish.room.TileHeight), -1);
                if (this.fish.room.aimap.TileAccessibleToCreature(worldCoordinate2.Tile, this.creature.creatureTemplate) && base.pathFinder.CoordinateReachableAndGetbackable(worldCoordinate2))
                {
                    this.exploreCoordinate = new WorldCoordinate?(worldCoordinate2);
                }
            }
            if (Custom.DistLess(this.creature.pos, base.pathFinder.GetDestination, 20f) && this.fish.room.VisualContact(this.creature.pos, base.pathFinder.GetDestination))
            {
                this.floatGoalPos = new Vector2?(this.fish.room.MiddleOfTile(base.pathFinder.GetDestination));
            }
            else
            {
                this.floatGoalPos = null;
            }
            break;

        case SeaDrakeAI.Behavior.Flee:
        {
            WorldCoordinate destination = base.threatTracker.FleeTo(this.creature.pos, 3, 30, this.currentUtility > 0.3f);
            if (base.threatTracker.mostThreateningCreature != null)
            {
                this.focusCreature = base.threatTracker.mostThreateningCreature;
            }
            this.creature.abstractAI.SetDestination(destination);
            this.floatGoalPos = null;
            break;
        }

        case SeaDrakeAI.Behavior.Hunt:
            this.attackCounter--;
            this.focusCreature = base.preyTracker.MostAttractivePrey;
            if (this.focusCreature.VisualContact)
            {
                this.floatGoalPos = new Vector2?(this.focusCreature.representedCreature.realizedCreature.mainBodyChunk.pos);
            }
            else
            {
                this.creature.abstractAI.SetDestination(this.focusCreature.BestGuessForPosition());
            }
            if (this.focusCreature.VisualContact && this.focusCreature.representedCreature.realizedCreature.collisionLayer != this.fish.collisionLayer && Custom.DistLess(this.focusCreature.representedCreature.realizedCreature.mainBodyChunk.pos, this.fish.bodyChunks[2].pos, this.fish.bodyChunks[2].rad + this.focusCreature.representedCreature.realizedCreature.mainBodyChunk.rad))
            {
                this.fish.Collide(this.focusCreature.representedCreature.realizedCreature, 2, 0);
            }
            break;

        case SeaDrakeAI.Behavior.ExamineSound:
            if (this.fish != null)
            {
                this.floatGoalPos = new Vector2?(this.fish.room.MiddleOfTile(this.noiseTracker.ExaminePos));
            }
            else
            {
                this.creature.abstractAI.SetDestination(base.noiseTracker.ExaminePos);
            }
            break;

        case SeaDrakeAI.Behavior.EscapeRain:
            if (base.denFinder.GetDenPosition() != null)
            {
                this.creature.abstractAI.SetDestination(base.denFinder.GetDenPosition().Value);
            }
            this.floatGoalPos = null;
            break;

        case SeaDrakeAI.Behavior.ReturnPrey:
            if (base.denFinder.GetDenPosition() != null)
            {
                this.creature.abstractAI.SetDestination(base.denFinder.GetDenPosition().Value);
            }
            this.floatGoalPos = null;
            break;

        case SeaDrakeAI.Behavior.GoToFood:
            this.creature.abstractAI.SetDestination(this.fish.room.GetWorldCoordinate(this.goToFood.firstChunk.pos));
            break;

        case SeaDrakeAI.Behavior.GetUnstuck:
            this.creature.abstractAI.SetDestination(base.stuckTracker.getUnstuckPosCalculator.unstuckGoalPosition);
            if (UnityEngine.Random.value < Custom.LerpMap(base.stuckTracker.Utility(), 0.9f, 1f, 0f, 0.1f) && this.fish.room.GetTile(this.fish.mainBodyChunk.pos).AnyWater&& this.fish.enteringShortCut == null && base.stuckTracker.stuckCloseToShortcutModule.foundShortCut != null)
            {
                this.fish.enteringShortCut = base.stuckTracker.stuckCloseToShortcutModule.foundShortCut;
                base.stuckTracker.Reset();
            }
            break;
        }
    }
Ejemplo n.º 15
0
 /// <summary>
 /// Used to split the tile in 11x11 real world coordinates matrix, starting from south west to north east.
 /// The latitude step between two points is Math.Abs(Math.Abs(northEast.Lat) - Math.Abs(southWest.Lat))/(tileWidth - 1).
 /// </summary>
 /// <param name="i">The index of the processed vertex</param>
 /// <param name="tileWidth">The edge size, in vertices number.</param>
 /// <param name="distanceBetweenPoints">Delta latitude between two vertices</param>
 /// <param name="precLat">Latitude of precedent vertex</param>
 /// <returns>The latitude for the processed vertex</returns>
 private double GetLatFromSouthWest(double i, double tileWidth, double distanceBetweenPoints, WorldCoordinate precLat)
 {
     return(precLat.Lat + (distanceBetweenPoints * Math.Floor(i / tileWidth)));
 }
Ejemplo n.º 16
0
 public AbstractDestruction(World world, WorldCoordinate pos, Vector2 realPos, float rad, EntityID ID, bool affectTerrain = true) : base(world, pos, ID)
 {
     this.realPos       = realPos;
     this.rad           = (int)rad;
     this.affectTerrain = affectTerrain;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Used to split the tile in 11x11 real world coordinates matrix, starting from south west to north east.
 /// The longitude step between two points is Math.Abs(Math.Abs(northEast.Lon) - Math.Abs(southWest.Lon)) / (tileWidth - 1).
 /// </summary>
 /// <param name="i">The index of the processed vertex</param>
 /// <param name="tileWidth">The edge size, in vertices number.</param>
 /// <param name="distanceBetweenPoints">Delta latitude between two vertices</param>
 /// <param name="precLng">Longitude of precedent vertex</param>
 /// <returns>The longitude for the processed vertex</returns>
 private double GetLngFromSouthWest(double i, double tileWidth, double distanceBetweenPoints, WorldCoordinate precLng)
 {
     return(precLng.Lon + (distanceBetweenPoints * (i % tileWidth)));
 }
Ejemplo n.º 18
0
 void OnPositionChanged(WorldCoordinate pPrevPos, WorldCoordinate pNewPos)
 {
     UpdateMovingDoorPosition();
 }
Ejemplo n.º 19
0
        private void SpawnEntity(SandboxEditor.PlacedIconData placedIconData)
        {
            IconSymbol.IconSymbolData data = placedIconData.data;
            WorldCoordinate           pos  = new WorldCoordinate(0, -1, -1, -1);

            pos.x = Mathf.RoundToInt(placedIconData.pos.x / 20f);
            pos.y = Mathf.RoundToInt(placedIconData.pos.y / 20f);
            EntityID entityID = (!base.GameTypeSetup.saveCreatures) ? this.game.GetNewID() : placedIconData.ID;

            if (data.itemType == AbstractPhysicalObject.AbstractObjectType.Creature)
            {
                AbstractCreature abstractCreature = null;
                if (base.GameTypeSetup.saveCreatures)
                {
                    for (int i = 0; i < this.arenaSitting.creatures.Count; i++)
                    {
                        if (this.arenaSitting.creatures[i].creatureTemplate.type == data.critType && this.arenaSitting.creatures[i].ID == entityID)
                        {
                            abstractCreature = this.arenaSitting.creatures[i];
                            this.arenaSitting.creatures.RemoveAt(i);
                            for (int j = 0; j < 2; j++)
                            {
                                abstractCreature.state.CycleTick();
                            }
                            string creatureString = SaveState.AbstractCreatureToString(abstractCreature);
                            abstractCreature     = SaveState.AbstractCreatureFromString(this.game.world, creatureString, false);
                            abstractCreature.pos = pos;
                            break;
                        }
                    }
                }
                if (abstractCreature == null)
                {
                    abstractCreature = new AbstractCreature(this.game.world, StaticWorld.GetCreatureTemplate(data.critType), null, pos, entityID);
                }
                CreatureTemplate.Type critType = data.critType;
                switch (critType)
                {
                case CreatureTemplate.Type.TentaclePlant:
                case CreatureTemplate.Type.PoleMimic:
                    abstractCreature.pos.x            = -1;
                    abstractCreature.pos.y            = -1;
                    abstractCreature.pos.abstractNode = data.intData;
                    this.game.world.GetAbstractRoom(0).entitiesInDens.Add(abstractCreature);
                    break;

                default:
                    switch (critType)
                    {
                    case CreatureTemplate.Type.Fly:
                    case CreatureTemplate.Type.Leech:
                    case CreatureTemplate.Type.SeaLeech:
                        for (int k = 0; k < 5; k++)
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(new AbstractCreature(this.game.world, StaticWorld.GetCreatureTemplate(data.critType), null, pos, entityID));
                        }
                        break;

                    default:
                        if (critType == CreatureTemplate.Type.Slugcat)
                        {
                            if (this.playerSpawnDens == null)
                            {
                                this.playerSpawnDens = new List <int>();
                            }
                            this.playerSpawnDens.Add(data.intData);
                        }
                        if (critType != CreatureTemplate.Type.Spider)
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(abstractCreature);
                        }
                        break;
                    }
                    break;

                case CreatureTemplate.Type.Centipede:
                {
                    float num = 0f;
                    if (data.intData == 2)
                    {
                        num = Mathf.Lerp(0.265f, 0.55f, Mathf.Pow(Custom.ClampedRandomVariation(0.5f, 0.5f, 0.7f), 1.2f));
                    }
                    else if (data.intData == 3)
                    {
                        num = Mathf.Lerp(0.7f, 1f, Mathf.Pow(UnityEngine.Random.value, 0.6f));
                    }
                    abstractCreature.spawnData = "{" + num.ToString() + "}";
                    this.game.world.GetAbstractRoom(0).AddEntity(abstractCreature);
                    break;
                }
                }
            }
            else
            {
                AbstractPhysicalObject.AbstractObjectType itemType = data.itemType;
                if (itemType != AbstractPhysicalObject.AbstractObjectType.Spear)
                {
                    if (itemType != AbstractPhysicalObject.AbstractObjectType.WaterNut)
                    {
                        if (itemType != AbstractPhysicalObject.AbstractObjectType.SporePlant)
                        {
                            if (itemType != AbstractPhysicalObject.AbstractObjectType.BubbleGrass)
                            {
                                if (AbstractConsumable.IsTypeConsumable(data.itemType))
                                {
                                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractConsumable(this.game.world, data.itemType, null, pos, entityID, -1, -1, null));
                                }
                                else
                                {
                                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractPhysicalObject(this.game.world, data.itemType, null, pos, entityID));
                                }
                            }
                            else
                            {
                                this.game.world.GetAbstractRoom(0).AddEntity(new BubbleGrass.AbstractBubbleGrass(this.game.world, null, pos, entityID, 1f, -1, -1, null));
                            }
                        }
                        else
                        {
                            this.game.world.GetAbstractRoom(0).AddEntity(new SporePlant.AbstractSporePlant(this.game.world, null, pos, entityID, -1, -1, null, false, true));
                        }
                    }
                    else
                    {
                        this.game.world.GetAbstractRoom(0).AddEntity(new WaterNut.AbstractWaterNut(this.game.world, null, pos, entityID, -1, -1, null, false));
                    }
                }
                else
                {
                    this.game.world.GetAbstractRoom(0).AddEntity(new AbstractSpear(this.game.world, null, pos, entityID, data.intData == 1));
                }
            }
        }
Ejemplo n.º 20
0
 public WorldCoordinate ReadWorldCoordinate()
 {
     return(WorldCoordinate.FromStream(this));
 }