Exemple #1
0
        public void WriteToFile(BinaryWriter Writer)
        {
            Writer.Write(Unk02);
            Writer.Write(Unk03);
            Writer.Write(Unk04);
            StringHelpers.WriteString16(Writer, PartName);
            Writer.Write(Unk05);
            StringHelpers.WriteString16(Writer, KynogonString);
            StringHelpers.WriteString16(Writer, Unk01);
            StringHelpers.WriteString16(Writer, ConstAIWorldPart);
            Writer.Write(Unk06);

            // Write AI Points
            Writer.Write(AIPoints.Count);
            foreach (IType AIPoint in AIPoints)
            {
                ushort TypeID = AIWorld_Factory.GetIDByType(AIPoint);
                Writer.Write(TypeID);
                AIPoint.Write(Writer);
            }

            // Write footer data
            StringHelpers.WriteString(Writer, OriginStream);
            Writer.Write(OriginStream.Length + 1);
            Writer.Write(Unk8);
            Writer.Write(Unk9);
            Writer.Write(Unk10);
        }
Exemple #2
0
        public void DebugWriteToFile()
        {
            using (StreamWriter Writer = new StreamWriter(PartName + ".txt"))
            {
                Writer.WriteLine("Unk01: {0}", Unk01);
                Writer.WriteLine("Unk02: {0}", Unk02);
                Writer.WriteLine("Unk03: {0}", Unk03);
                Writer.WriteLine("Unk04: {0}", Unk04);
                Writer.WriteLine("PartName: {0}", PartName);
                Writer.WriteLine("Unk05: {0}", Unk05);
                Writer.WriteLine("KynogonString: {0}", KynogonString);
                Writer.WriteLine("ConstAIWorldPart: {0}", ConstAIWorldPart);
                Writer.WriteLine("Unk06: {0}", Unk06);

                foreach (IType AIPoint in AIPoints)
                {
                    AIPoint.DebugWrite(Writer);
                    Writer.WriteLine("");
                }

                Writer.WriteLine("OriginStream: {0}", OriginStream);
                Writer.WriteLine("Unk8: {0}", Unk8);
                Writer.WriteLine("Unk9: {0}", Unk9);
                Writer.WriteLine("Unk10: {0}", Unk10);
            }
        }
Exemple #3
0
 public void PopulatePrimitiveBatch(PrimitiveBatch BBoxBatch)
 {
     foreach (IType AIPoint in AIPoints)
     {
         if (AIPoint.bIsVisible)
         {
             AIPoint.ConstructRenderable(BBoxBatch);
         }
     }
 }
        public override void ConstructRenderable(PrimitiveBatch BBoxBatcher)
        {
            base.ConstructRenderable(BBoxBatcher);

            foreach (IType AIPoint in AIPoints)
            {
                if (AIPoint.bIsVisible)
                {
                    AIPoint.ConstructRenderable(BBoxBatcher);
                }
            }
        }
        public override void DebugWrite(StreamWriter Writer)
        {
            base.DebugWrite(Writer);

            Writer.WriteLine("Unk0: {0}", Unk01);
            Writer.WriteLine("NumPoints: {0}", AIPoints.Length);
            foreach (IType AIPoint in AIPoints)
            {
                AIPoint.DebugWrite(Writer);
                Writer.WriteLine("");
            }
        }
        public override void Write(BinaryWriter Writer)
        {
            base.Write(Writer);

            Writer.Write(Unk01);
            Writer.Write(AIPoints.Length);

            foreach (IType AIPoint in AIPoints)
            {
                ushort TypeID = AIWorld_Factory.GetIDByType(AIPoint);
                Writer.Write(TypeID);
                AIPoint.Write(Writer);
            }
        }
Exemple #7
0
        public TreeNode PopulateTreeNode()
        {
            TreeNode Parent = new TreeNode();

            Parent.Text = PartName;
            Parent.Name = PartName;
            Parent.Tag  = this;

            foreach (IType AIPoint in AIPoints)
            {
                Parent.Nodes.Add(AIPoint.PopulateTreeNode());
            }

            return(Parent);
        }
        public override TreeNode PopulateTreeNode()
        {
            base.PopulateTreeNode();

            TreeNode ThisNode = new TreeNode();

            ThisNode.Text = "Type1 Group";
            ThisNode.Name = RefID.ToString();
            ThisNode.Tag  = this;

            foreach (IType AIPoint in AIPoints)
            {
                ThisNode.Nodes.Add(AIPoint.PopulateTreeNode());
            }

            return(ThisNode);
        }
Exemple #9
0
    public AIMovePoint GetBestMovePointNear(Vector3 targetPosition, Vector3 fromPosition, float minRange, float maxRange, bool checkLOS = false, BaseEntity forObject = null, bool returnClosest = false)
    {
        AIPoint aIPoint  = null;
        AIPoint aIPoint2 = null;
        float   num      = -1f;
        float   num2     = float.PositiveInfinity;
        int     pointCount;

        AIPoint[] movePointsInRange = GetMovePointsInRange(targetPosition, maxRange, out pointCount);
        if (movePointsInRange == null || pointCount <= 0)
        {
            return(null);
        }
        for (int i = 0; i < pointCount; i++)
        {
            AIPoint aIPoint3 = movePointsInRange[i];
            if (!aIPoint3.transform.parent.gameObject.activeSelf || (!(fromPosition.y < WaterSystem.OceanLevel) && aIPoint3.transform.position.y < WaterSystem.OceanLevel))
            {
                continue;
            }
            float   num3     = 0f;
            Vector3 position = aIPoint3.transform.position;
            float   num4     = Vector3.Distance(targetPosition, position);
            if (num4 < num2)
            {
                aIPoint2 = aIPoint3;
                num2     = num4;
            }
            if (!(num4 > maxRange))
            {
                num3 += (aIPoint3.CanBeUsedBy(forObject) ? 100f : 0f);
                num3 += (1f - Mathf.InverseLerp(minRange, maxRange, num4)) * 100f;
                if (!(num3 < num) && (!checkLOS || !UnityEngine.Physics.Linecast(targetPosition + Vector3.up * 1f, position + Vector3.up * 1f, 1218519297, QueryTriggerInteraction.Ignore)) && num3 > num)
                {
                    aIPoint = aIPoint3;
                    num     = num3;
                }
            }
        }
        if (aIPoint == null && returnClosest)
        {
            return(aIPoint2 as AIMovePoint);
        }
        return(aIPoint as AIMovePoint);
    }
Exemple #10
0
    private AIMovePoint GetBestRoamPoint(AIInformationZone aiZone, Vector3 anchorPos, Vector3 currentPos, Vector3 currentDirection, float clampDistance, float lookupMaxRange)
    {
        if (aiZone == null)
        {
            return(null);
        }
        bool    flag    = clampDistance > -1f;
        float   num     = float.NegativeInfinity;
        AIPoint aIPoint = null;
        int     pointCount;

        AIPoint[] movePointsInRange = aiZone.GetMovePointsInRange(anchorPos, lookupMaxRange, out pointCount);
        if (movePointsInRange == null || pointCount <= 0)
        {
            return(null);
        }
        for (int i = 0; i < pointCount; i++)
        {
            AIPoint aIPoint2 = movePointsInRange[i];
            if (!aIPoint2.transform.parent.gameObject.activeSelf)
            {
                continue;
            }
            float num2  = Mathf.Abs(currentPos.y - aIPoint2.transform.position.y);
            bool  flag2 = currentPos.y < WaterSystem.OceanLevel;
            if (!flag2 && ((!flag2 && aIPoint2.transform.position.y < WaterSystem.OceanLevel) || (currentPos.y >= WaterSystem.OceanLevel && num2 > 5f)))
            {
                continue;
            }
            float num3  = 0f;
            float value = Vector3.Dot(currentDirection, Vector3Ex.Direction2D(aIPoint2.transform.position, currentPos));
            num3 += Mathf.InverseLerp(-1f, 1f, value) * 100f;
            if (!aIPoint2.InUse())
            {
                num3 += 1000f;
            }
            num3 += (1f - Mathf.InverseLerp(1f, 10f, num2)) * 100f;
            float num4 = Vector3.Distance(currentPos, aIPoint2.transform.position);
            if (num4 <= 1f)
            {
                num3 -= 3000f;
            }
            if (flag)
            {
                float num5 = Vector3.Distance(anchorPos, aIPoint2.transform.position);
                if (num5 <= clampDistance)
                {
                    num3 += 1000f;
                    num3 += (1f - Mathf.InverseLerp(0f, clampDistance, num5)) * 200f * Random.Range(0.8f, 1f);
                }
            }
            else if (num4 > 3f)
            {
                num3 += Mathf.InverseLerp(3f, lookupMaxRange, num4) * 50f;
            }
            if (num3 > num)
            {
                aIPoint = aIPoint2;
                num     = num3;
            }
        }
        return(aIPoint as AIMovePoint);
    }
        protected override void DoAction(ServerCurrentStateTransferMessage message, Entity entity, System.TimeSpan gameTime)
        {
            var ai       = entity.GetComponent <AIComponent>();
            var simpleAI = (SimpleAI)ai.AIBot;

            for (var i = 0; i < simpleAI.Players.Count; i++)
            {
                simpleAI.Players[i].Free();
            }
            simpleAI.Players.Clear();

            for (var i = 0; i < message.Players.Count; i++)
            {
                var player = AIPlayerState.Create();
                simpleAI.Players.Add(player);
                player.LevelScore = message.Players[i].LevelScore;
                player.PlayerId   = message.Players[i].PlayerId;
                player.TotalScore = message.Players[i].TotalScore;

                for (var j = 0; j < message.Players[i].Units.Count; j++)
                {
                    var unit = AIPlayerState.UnitSubMessage.Create();
                    player.Units.Add(unit);
                    unit.Hp         = message.Players[i].Units[j].Hp;
                    unit.UnitId     = message.Players[i].Units[j].UnitId;
                    unit.Position   = AIPlayerState.PointSubMessage.Create();
                    unit.Position.X = message.Players[i].Units[j].Position.X;
                    unit.Position.Y = message.Players[i].Units[j].Position.Y;
                }
            }

            if (message.Exit != null)
            {
                simpleAI.Exit   = simpleAI.Exit ?? AIPoint.Create();
                simpleAI.Exit.X = message.Exit.X;
                simpleAI.Exit.Y = message.Exit.Y;
            }

            var width  = simpleAI.Regions.GetLength(0);
            var height = simpleAI.Regions.GetLength(1);

            for (var x = 0; x < width; x++)
            {
                for (var y = 0; y < height; y++)
                {
                    var map = message.Map[x * height + y];
                    switch (map)
                    {
                    case RegionValue.Unknown:
                    {
                        break;
                    }

                    case RegionValue.Path:
                    {
                        simpleAI.Regions[x, y] = map;
                        break;
                    }

                    case RegionValue.Wall:
                    {
                        simpleAI.Regions[x, y] = map;
                        simpleAI.Pathfinding.Walls.Add(new BrainAI.Pathfinding.Point(x, y));
                        break;
                    }
                    }
                }
            }
        }