コード例 #1
0
 public object IGCPackGeneric()
 {
     return(MyTuple.Create
            (
                (int)Type,
                ID,
                MyTuple.Create
                (
                    MyTuple.Create
                    (
                        CurrentPosition,
                        CurrentVelocity,
                        CurrentCanonicalTime.TotalMilliseconds,
                        LastValidatedCanonicalTime.TotalMilliseconds
                    ),
                    MyTuple.Create
                    (
                        DisplayName,
                        ID,
                        Radius,
                        (int)CubeSize
                    )
                )
            ));
 }
コード例 #2
0
        public ITask GenerateMoveToAndDockTask(MyTuple <IntelItemType, long> intelKey, Dictionary <MyTuple <IntelItemType, long>, IFleetIntelligence> IntelItems, float approachMaxSpeed = 100)
        {
            if (intelKey.Item1 == IntelItemType.NONE && intelKey.Item1 == 0)
            {
                intelKey = MyTuple.Create(IntelItemType.Dock, DockingSubsystem.HomeID);
            }

            if (intelKey.Item1 != IntelItemType.Dock)
            {
                return(new NullTask());
            }

            if (!IntelItems.ContainsKey(intelKey))
            {
                return(new NullTask());
            }

            if (DockingSubsystem.Connector.Status == MyShipConnectorStatus.Connected && DockingSubsystem.Connector.OtherConnector.EntityId == intelKey.Item2)
            {
                return(new NullTask());
            }

            var Dock = (DockIntel)IntelItems[intelKey];

            holdTask.Destination.MaxSpeed = approachMaxSpeed;

            Task.Reset(holdTask, approachTask, enterTask, closeTask, dockTask, intelKey, Program, DockingSubsystem.Connector.CubeGrid.GridSizeEnum, DockingSubsystem.Connector, DockingSubsystem.DirectionIndicator);

            return(Task);
        }
コード例 #3
0
        public void Do(Dictionary <MyTuple <IntelItemType, long>, IFleetIntelligence> IntelItems, TimeSpan canonicalTime, Profiler profiler)
        {
            if (IntelKey.Item1 == IntelItemType.NONE && IntelKey.Item2 == 0)
            {
                DockingSubsystem.HomeID = -1;
                Status = TaskStatus.Complete;
                return;
            }

            if (!IntelItems.ContainsKey(IntelKey))
            {
                Status = TaskStatus.Aborted;
                return;
            }

            var dock = (DockIntel)IntelItems[IntelKey];

            if (dock.OwnerID == MyId && (dock.Status & HangarStatus.Reserved) != 0)
            {
                Status = TaskStatus.Complete;
                DockingSubsystem.HomeID = dock.ID;
                return;
            }

            Program.IGC.SendBroadcastMessage(dock.HangarChannelTag, MyTuple.Create(MyId, dock.ID, (int)HangarRequest.Reserve));
        }
コード例 #4
0
        void Designate(TimeSpan localTime)
        {
            if (Designator == null)
            {
                return;
            }
            double distance = RaycastDistanceMax;

            if (Designator.RaycastDistanceLimit >= 0)
            {
                distance = Math.Min(distance, Designator.RaycastDistanceLimit);
            }

            var designateInfo = Designator.Raycast(distance);

            if (designateInfo.Type != MyDetectedEntityType.LargeGrid && designateInfo.Type != MyDetectedEntityType.SmallGrid)
            {
                return;
            }

            if (designateInfo.Relationship != MyRelationsBetweenPlayerAndBlock.Enemies && designateInfo.Relationship != MyRelationsBetweenPlayerAndBlock.Neutral)
            {
                return;
            }

            var intelDict   = IntelProvider.GetFleetIntelligences(localTime);
            var key         = MyTuple.Create(IntelItemType.Enemy, designateInfo.EntityId);
            var TargetIntel = intelDict.ContainsKey(key) ? (EnemyShipIntel)intelDict[key] : new EnemyShipIntel();

            TargetIntel.FromDetectedInfo(designateInfo, localTime + IntelProvider.CanonicalTimeDiff);
            IntelProvider.ReportFleetIntelligence(TargetIntel, localTime);
        }
コード例 #5
0
 public object IGCPackGeneric()
 {
     return(MyTuple.Create
            (
                (int)Type,
                ID,
                MyTuple.Create
                (
                    MyTuple.Create
                    (
                        WorldMatrix,
                        UndockFar,
                        UndockNear,
                        CurrentVelocity,
                        CurrentCanonicalTime.TotalMilliseconds,
                        IndicatorDir
                    ),
                    MyTuple.Create
                    (
                        OwnerID,
                        (int)Status,
                        (int)Tags,
                        HangarChannelTag
                    ),
                    MyTuple.Create
                    (
                        ID,
                        DisplayName
                    )
                )
            ));
 }
コード例 #6
0
 void AddTaskFromCommand(TimeSpan timestamp, MyTuple <int, MyTuple <int, long>, int, int> command)
 {
     if (timestamp == TimeSpan.Zero)
     {
         return;
     }
     AddTask((TaskType)command.Item1, MyTuple.Create((IntelItemType)command.Item2.Item1, command.Item2.Item2), (CommandType)command.Item3, command.Item4, timestamp + IntelProvider.CanonicalTimeDiff);
 }
コード例 #7
0
            bool FireTorpedoAtCursorTarget(string group, TimeSpan localTime)
            {
                var intelItems = Host.IntelProvider.GetFleetIntelligences(localTime);
                var key        = MyTuple.Create(IntelItemType.Enemy, closestEnemyToCursorID);
                var target     = (EnemyShipIntel)intelItems.GetValueOrDefault(key, null);

                return(HostProgram.TorpedoSubsystem.Fire(localTime, HostProgram.TorpedoSubsystem.TorpedoTubeGroups[group], target, false) != null);
            }
コード例 #8
0
 public bool PackAndBroadcastFleetIntelligence(ExecutionContext context, IFleetIntelligence item, long masterID)
 {
     if (item is INTEL)
     {
         context.IGC.SendBroadcastMessage(IntelReportChannelTag, MyTuple.Create(masterID, (DATA)item.IGCPackGeneric()));
         return(true);
     }
     return(false);
 }
コード例 #9
0
        private IEnumerable <MyTuple <Vector4I, Vector4D> > GetSpawnsIn(Vector4I cell, BoundingBoxD aabbGlobal, Func <BoundingBoxD, bool> test)
        {
            var aabb = GetNodeAABB(cell);

            if (!aabbGlobal.Intersects(aabb))
            {
                yield break;
            }
            if (test != null && !test.Invoke(aabb))
            {
                yield break;
            }

            var densityNoise = m_densityNoise.GetValue(aabb.Center) * m_depth;
            var depthDensity = (int)MyMath.Clamp((float)Math.Floor(densityNoise), 0, m_depth - 1);

            if (depthDensity <= cell.W)
            {
                var localDensity = densityNoise - depthDensity;
                // When local density is zero we just came from a subdivision which means there is a (1/8) chance.  When it is one we want 100% chance.
                var probability   = (1 + localDensity * 7) / 8.0;
                var placementRoll = MyMath.Clamp((float)(m_probabilityModule.GetValue(aabb.Center) + 1) / 2, 0, 1);
                if (placementRoll <= probability)
                {
                    yield break;
                }

                // Try to spawn in this cell.
                var placement = new Vector3(SampleNoiseNorm(m_placementNoise[0], aabb.Center),
                                            SampleNoiseNorm(m_placementNoise[1], aabb.Center),
                                            SampleNoiseNorm(m_placementNoise[2], aabb.Center));

                var warp = new Vector3(SampleNoiseNorm(m_warpNoise[0], aabb.Center),
                                       SampleNoiseNorm(m_warpNoise[1], aabb.Center),
                                       SampleNoiseNorm(m_warpNoise[2], aabb.Center));

                var localPos = Vector3.Clamp((warp * 0.25f) + (placement * 0.75f), Vector3.MinusOne, Vector3.One);

                var worldPos = aabb.Center + aabb.HalfExtents * localPos;
                yield return(MyTuple.Create(cell, new Vector4D(worldPos, densityNoise / m_depth)));
            }
            else
            {
                // Subdivide.
                for (var i = 0; i < 8; i++)
                {
                    var x = (cell.X << 1) | (i & 1);
                    var y = (cell.Y << 1) | ((i >> 1) & 1);
                    var z = (cell.Z << 1) | ((i >> 2) & 1);
                    foreach (var k in GetSpawnsIn(new Vector4I(x, y, z, cell.W + 1), aabbGlobal, test))
                    {
                        yield return(k);
                    }
                }
            }
        }
コード例 #10
0
        // I need to return the arms back to origin without banging into anything; if I move arm 2 in the opposite way from arm 1 then they
        // should start to "scissor" together. At the same time, I need to move arm three in the _opposite_ direction, since the angle of arm 2 is changing.
        // Arm 3 will try to stay at the same angle

        // Or, I could "straighten out" if I've got wide angles (e.g. arm 2 is > 90 deg from arm 1)
        // or "curl up" if I've got narrow angles
        public List <MyTuple <String, float> > ResetArm1()
        {
            // if arm 2 is > 90 away from arm 1 then we're extended, so fully extend by going to -180
            // else we've got a very sharp elbow formed by arms 1 and 2 and we should take arm 2 back towards 0/360

            return(new List <MyTuple <String, float> >()
            {
                MyTuple.Create(HINGE, 0f),
            });
        }
コード例 #11
0
        public void Setup(ExecutionContext context, string name)
        {
            Context = context;

            CommandChannelTag = Context.Reference.CubeGrid.EntityId.ToString() + "-COMMAND";
            CommandListener   = Context.IGC.RegisterBroadcastListener(CommandChannelTag);
            //profiler = new Profiler(Program.Runtime, PROFILER_HISTORY_COUNT, PROFILER_NEW_VALUE_FACTOR);
            AddTask(TaskType.None, MyTuple.Create(IntelItemType.NONE, (long)0), CommandType.DoFirst, 2, TimeSpan.Zero);
            AddTaskFromCommand(TimeSpan.Zero, MyTuple.Create(-1, MyTuple.Create(0, (long)0), 0, 0));
        }
コード例 #12
0
        public static ContainmentType ContainsAdv(this MyOrientedBoundingBoxD obb, BoundingFrustumD frust, HashSet <Vector3D> internalPoints)
        {
            bool noCorners;
            var  ct = ContainsAdv(obb, frust, internalPoints, out noCorners);

            if (!noCorners)
            {
                var points     = new HashSet <Vector3D>(internalPoints);
                var planes     = new PlaneD[] { frust.Bottom, frust.Far, frust.Left, frust.Right, frust.Top, frust.Near };
                var lines      = obb.GetLines().Where(l => internalPoints.Contains(l.From) || internalPoints.Contains(l.To)).Select(l => new { Line = l, LengthSquared = l.Length * l.Length }).ToArray();
                var intersects = new List <MyTuple <LineD, double, Vector3D> >();
                for (int i = 0; i < lines.Length; i++)
                {
                    if (internalPoints.Contains(lines[i].Line.From) && internalPoints.Contains(lines[i].Line.To))
                    {
                        points.Add(lines[i].Line.From);
                        points.Add(lines[i].Line.To);
                        continue;
                    }
                    for (int j = 0; j < planes.Length; j++)
                    {
                        var line = lines[i];
                        if (internalPoints.Contains(line.Line.To))
                        {
                            line = new { Line = new LineD(line.Line.To, line.Line.From), LengthSquared = line.LengthSquared }
                        }
                        ;
                        var ln  = line.Line;
                        var res = planes[j].Intersection(ref ln.From, ref ln.Direction);
                        if (res.IsValid())
                        {
                            double len;
                            Vector3D.DistanceSquared(ref ln.From, ref res, out len);
                            if (len <= line.LengthSquared)
                            {
                                intersects.Add(MyTuple.Create(ln, len, res));
                            }
                        }
                    }
                }
                foreach (var pnt in intersects.GroupBy(k => k.Item1, LineDEqualityComparer.Instance).Select(k => k.OrderBy(x => x.Item2).First().Item3))
                {
                    points.Add(pnt);
                }
                internalPoints.Clear();
                foreach (var pnt in internalPoints)
                {
                    internalPoints.Add(pnt);
                }
            }
            return(ct);
        }
コード例 #13
0
            public void PackAndBroadcastFleetIntelligenceSyncPackage(ExecutionContext context, Dictionary <MyTuple <IntelItemType, long>, IFleetIntelligence> intelItems, long masterID)
            {
                Builder.Clear();
                foreach (var kvp in intelItems)
                {
                    if (Proxy.Type == kvp.Key.Item1)
                    {
                        Builder.Add(MyTuple.Create(masterID, (DATA)kvp.Value.IGCPackGeneric()));
                    }
                }
//                 context.Log.Debug("SEND " + Proxy.Type.ToString() + " " + data.GetType().ToString());
                context.IGC.SendBroadcastMessage(IntelSyncChannelTag, Builder.ToImmutable());
            }
コード例 #14
0
        void AutoHomeCrafts(TimeSpan localTime)
        {
            FriendlyShipScratchpad.Clear();
            DockIntelScratchpad.Clear();

            var intelItems = IntelProvider.GetFleetIntelligences(localTime);

            foreach (var kvp in intelItems)
            {
                if (kvp.Key.Item1 == IntelItemType.Friendly)
                {
                    var friendly = (FriendlyShipIntel)kvp.Value;
                    if (friendly.HomeID == -1 && !string.IsNullOrEmpty(friendly.CommandChannelTag))
                    {
                        FriendlyShipScratchpad.Add(friendly);
                    }
                }
                else if (kvp.Key.Item1 == IntelItemType.Dock)
                {
                    var dock = (DockIntel)kvp.Value;
                    if (dock.OwnerID == -1)
                    {
                        DockIntelScratchpad.Add(dock);
                    }
                }
            }

            if (FriendlyShipScratchpad.Count == 0)
            {
                return;
            }

            foreach (var craft in FriendlyShipScratchpad)
            {
                DockIntel targetDock = null;
                foreach (var dock in DockIntelScratchpad)
                {
                    if (DockIntel.TagsMatch(craft.HangarTags, dock.Tags))
                    {
                        targetDock = dock;
                        break;
                    }
                }

                if (targetDock != null)
                {
                    IntelProvider.ReportCommand(craft, TaskType.SetHome, MyTuple.Create(IntelItemType.Dock, targetDock.ID), localTime);
                    DockIntelScratchpad.Remove(targetDock);
                }
            }
        }
コード例 #15
0
        bool SubProcessSendBroadcastMessage()
        {
            var message = MyTuple.Create
                          (
                Me.CubeGrid.EntityId,
                Me.CubeGrid.CustomName,
                lastShipPosition,
                informationTerminals.Text
                          );

            IGC.SendBroadcastMessage(StateBroadcastTag, message);

            return(true);
        }
コード例 #16
0
 public void Do3(TimeSpan localTime)
 {
     if (CAPMode == 0)
     {
         CAPMode = 1;
         HostProgram.TaskGenerator.HornetAttackTask.Mode = 1;
     }
     else
     {
         CAPMode = 0;
         HostProgram.AgentSubsystem.AddTask(TaskType.None, MyTuple.Create(IntelItemType.NONE, (long)0), CommandType.Override, 0, TimeSpan.Zero);
         HostProgram.AutopilotSubsystem.Clear();
     }
 }
コード例 #17
0
        public void AddTaskGenerator(ITaskGenerator taskGenerator)
        {
            AvailableTasks |= taskGenerator.AcceptedTypes;
            for (int i = 0; i < 30; i++)
            {
                if ((1 << i & (int)taskGenerator.AcceptedTypes) != 0)
                {
                    TaskGenerators[(TaskType)(1 << i)] = taskGenerator;
                }
            }

            // JIT?
            taskGenerator.GenerateTask(TaskType.None, MyTuple.Create(IntelItemType.NONE, (long)0), new Dictionary <MyTuple <IntelItemType, long>, IFleetIntelligence>(), TimeSpan.Zero, 0);
        }
コード例 #18
0
 public object IGCPackGeneric()
 {
     return(MyTuple.Create
            (
                (int)Type,
                ID,
                MyTuple.Create
                (
                    Position,
                    Radius,
                    ID
                )
            ));
 }
コード例 #19
0
 public void UpdateState(TimeSpan localTime)
 {
     if (CAPMode != 0)
     {
         if (HostProgram.AgentSubsystem.TaskQueue.Count == 0)
         {
             if (closestEnemyToCursorID != -1)
             {
                 HostProgram.AgentSubsystem.AddTask(TaskType.Attack, MyTuple.Create(IntelItemType.Enemy, closestEnemyToCursorID), CommandType.Override, 0,
                                                    localTime + HostProgram.IntelSubsystem.CanonicalTimeDiff);
             }
         }
     }
 }
コード例 #20
0
                //adds items to the cargo list in a controlled fashion. Serves for transfering
                public void addItem(long vfID, MyFixedPoint vfFreespace, string vfType, string vfSubType, MyFixedPoint vfQuant, int vfPos)
                {
                    /*I have tried to make a tuple list within a tuple list to save memory and spare repeated IDs and Freespaces, but the search for items became
                     * too complex and cumbersome. I will get the wasted memory back in CPU power and ease of programming and usage, so it's fine, I suppose*/
                    //check if id in question exists.
                    MaterialList.Add(MyTuple.Create(vfID, vfFreespace, vfType, vfSubType, vfQuant, vfPos));

                    //if type is empty it means we're just marking the id and free space in the list. No need to update the quantity of an item that does not exist
                    if (vfType != "")
                    {
                        addQuantities(vfSubType, vfType, (float)vfQuant);
                        addCheck(vfSubType, vfType, vfID);
                    }
                }
コード例 #21
0
        private static void RegisterPoolsFromAssembly(Assembly assembly)
        {
#if XB1 // XB1_ALLINONEASSEMBLY
            System.Diagnostics.Debug.Assert(m_registered == false);
            if (m_registered == true)
            {
                return;
            }
            m_registered = true;
            foreach (var type in MyAssembly.GetTypes())
#else // !XB1
            foreach (var type in assembly.GetTypes())
#endif // !XB1
            {
                var customAttributes = type.GetCustomAttributes(typeof(PooledObjectAttribute), false);
                if (customAttributes != null && customAttributes.Length > 0)
                {
                    Debug.Assert(customAttributes.Length == 1);
                    PooledObjectAttribute attribute = (PooledObjectAttribute)customAttributes[0];
                    var  methods       = type.GetMethods();
                    bool delegateFound = false;
                    foreach (var method in methods)
                    {
                        var methodAttributes = method.GetCustomAttributes(typeof(PooledObjectCleanerAttribute), false);
                        if (methodAttributes != null && methodAttributes.Length > 0)
                        {
                            Debug.Assert(methodAttributes.Length == 1);
                            MyGenericObjectPool objectPool      = new MyGenericObjectPool(attribute.PoolPreallocationSize, type);
                            CleanerDelegate     cleanerDelegate = method.CreateDelegate <CleanerDelegate>();

                            // Make sure everything in the pool is always clean
                            foreach (var objectInPool in objectPool.Unused)
                            {
                                cleanerDelegate(objectInPool);
                            }

                            m_poolsByType.Add(type, MyTuple.Create(objectPool, cleanerDelegate));
                            delegateFound = true;
                            break;
                        }
                    }

                    if (!delegateFound)
                    {
                        Debug.Fail("Pooled type does not have a cleaner method.");
                    }
                }
            }
        }
コード例 #22
0
        public IEnumerable <MatrixI> GetTransform(PartMount otherMount)
        {
            HashSet <MatrixI> output;

            if (MountCache.TryGet(MyTuple.Create(otherMount, this), out output))
            {
                return(output?.Select(x =>
                {
                    MatrixI val;
                    MatrixI.Invert(ref x, out val);
                    return val;
                }));
            }
            return(MountCache.GetOrCreate(MyTuple.Create(this, otherMount), GetTransformInternal));
        }
コード例 #23
0
        private MyTuple <MyDefinitionId, Vector3I, Vector3D, float, IReadOnlyDictionary <string, int> > BlockDataToTuple(IMySlimBlock Block)
        {
            MyDefinitionId           id                = Block.BlockDefinition.Id;
            Vector3I                 gridPos           = Block.Position;
            Vector3D                 worldPos          = Block.CubeGrid.GridIntegerToWorld(Block.Position);
            float                    integrityRatio    = (Block.BuildIntegrity - Block.CurrentDamage) / Block.MaxIntegrity;
            Dictionary <string, int> missingComponents = new Dictionary <string, int>();

            if (integrityRatio < 1 && Block.StockpileAllocated)
            {
                Block.GetMissingComponents(missingComponents);
            }

            return(MyTuple.Create <MyDefinitionId, Vector3I, Vector3D, float, IReadOnlyDictionary <string, int> >(id, gridPos, worldPos, integrityRatio, missingComponents));
        }
コード例 #24
0
 public void ReportCommand(FriendlyShipIntel agent, TaskType taskType, MyTuple <IntelItemType, long> targetKey, TimeSpan timestamp, CommandType commandType = CommandType.Override)
 {
     if (Host != null)
     {
         Host.ReportCommand(agent, taskType, targetKey, timestamp, commandType);
     }
     if (agent.ID == Context.Reference.CubeGrid.EntityId && MyAgent != null)
     {
         MyAgent.AddTask(taskType, targetKey, CommandType.Override, 0, timestamp + CanonicalTimeDiff);
     }
     else
     {
         Context.IGC.SendBroadcastMessage(agent.CommandChannelTag, MyTuple.Create((int)taskType, MyTuple.Create((int)targetKey.Item1, targetKey.Item2), (int)commandType, 0));
     }
 }
コード例 #25
0
            public void Do3()
            {
                var localTime = Host.Context.LocalTime;

                Host.ActiveLookingGlass.DoScan(localTime);
                if (!Host.ActiveLookingGlass.LastDetectedInfo.IsEmpty() && Host.ActiveLookingGlass.LastDetectedInfo.Type == MyDetectedEntityType.Asteroid)
                {
                    var w = new Waypoint();
                    w.Position  = (Vector3D)Host.ActiveLookingGlass.LastDetectedInfo.HitPosition;
                    w.Direction = Host.ActiveLookingGlass.PrimaryCamera.WorldMatrix.Backward;
                    Host.ReportIntel(w, localTime);
                    HostProgram.AgentSubsystem.AddTask(TaskType.Mine, MyTuple.Create(IntelItemType.Waypoint, w.ID), CommandType.Override, 0,
                                                       localTime + HostProgram.IntelSubsystem.CanonicalTimeDiff);
                }
            }
コード例 #26
0
            MyTuple <double, APWaypoint> getDist(Vector3D pos, APWaypoint a, APWaypoint b)
            {
                Vector3D ab = b.WP.Coords - a.WP.Coords;
                Vector3D ap = pos - a.WP.Coords;

                if (ap.Dot(ab) <= 0)
                {
                    return(MyTuple.Create(ap.LengthSquared(), a));
                }
                Vector3D bp = pos - b.WP.Coords;

                return(bp.Dot(ab) >= 0
          ? MyTuple.Create(bp.LengthSquared(), b)
          : MyTuple.Create(ab.Cross(ap).LengthSquared() / ab.LengthSquared(), null as APWaypoint));
            }
コード例 #27
0
ファイル: MyBlur.cs プロジェクト: viktorius/Viktor
        private static int InitShaders(MyBlurDensityFunctionType densityFunctionType, int maxOffset, float depthDiscardThreshold)
        {
            bool useDepthDiscard = depthDiscardThreshold > 0;
            int  shaderKey       = GetShaderKey(densityFunctionType, maxOffset, useDepthDiscard);

            if (!m_blurShaders.ContainsKey(shaderKey))
            {
                ShaderMacro depthMacro = new ShaderMacro(useDepthDiscard ? "DEPTH_DISCARD_THRESHOLD" : "", useDepthDiscard ? depthDiscardThreshold : 1);

                var macrosHorizontal = new[] { new ShaderMacro("HORIZONTAL_PASS", null), new ShaderMacro("MAX_OFFSET", maxOffset), new ShaderMacro("DENSITY_FUNCTION", (int)densityFunctionType), depthMacro };
                var macrosVertical   = new[] { new ShaderMacro("VERTICAL_PASS", null), new ShaderMacro("MAX_OFFSET", maxOffset), new ShaderMacro("DENSITY_FUNCTION", (int)densityFunctionType), depthMacro };
                var shaderPair       = MyTuple.Create(MyShaders.CreatePs("Postprocess/Blur.hlsl", macrosHorizontal), MyShaders.CreatePs("Postprocess/Blur.hlsl", macrosVertical));
                m_blurShaders.Add(shaderKey, shaderPair);
            }
            return(shaderKey);
        }
コード例 #28
0
 public object IGCPackGeneric()
 {
     return(MyTuple.Create
            (
                (int)Type,
                ID,
                MyTuple.Create
                (
                    Position,
                    Direction,
                    DirectionUp,
                    MaxSpeed,
                    Name
                )
            ));
 }
コード例 #29
0
 //Attempt to agilize the access to values. Is agilize a word? Google sensei says it isn't.
 //Basically, I don't need to change this entire list. I just need to update values as I transfer them
 public float this[int viIndex]
 {
     get { return(__TransferList[viIndex].Item3); }
     set
     {
         //removes the value already in the ship from the list and if it's zero or below, removes it from the list
         if ((value == 0 && SetToTrimZeroes) || (value < 0 && SetToTrimNegatives))
         {
             __TransferList.RemoveAt(viIndex);   //no point cycling through this anymore
         }
         else
         {
             __TransferList[viIndex] = MyTuple.Create(__TransferList[viIndex].Item1, __TransferList[viIndex].Item2, value);   //updates the value to what we actually need to tranfer
         }
     }
 }
コード例 #30
0
        public void Do(Dictionary <MyTuple <IntelItemType, long>, IFleetIntelligence> IntelItems, TimeSpan canonicalTime, Profiler profiler)
        {
            if (canonicalTime == TimeSpan.Zero)
            {
                return;
            }

            if (WaitTask.Status == TaskStatus.Incomplete)
            {
                var dockKey = MyTuple.Create(IntelItemType.Dock, DockingSubsystem.Connector.OtherConnector.EntityId);

                if (!IntelItems.ContainsKey(dockKey))
                {
                    WaitTask.Status = TaskStatus.Complete;
                }
                else
                {
                    dock = (DockIntel)IntelItems[dockKey];
                    if ((dock.Status & HangarStatus.Launching) != 0)
                    {
                        WaitTask.Status = TaskStatus.Complete;
                    }
                    else
                    {
                        Program.IGC.SendBroadcastMessage(dock.HangarChannelTag, MyTuple.Create(Program.Me.CubeGrid.EntityId, dock.ID, (int)HangarRequest.RequestLaunch));
                    }
                }
            }
            else
            {
                if (DockingSubsystem.Connector.Status == MyShipConnectorStatus.Connected)
                {
                    DockingSubsystem.Undock();
                }

                AutopilotSubsystem.Drift(Drift);
                AutopilotSubsystem.Controller.DampenersOverride = false;

                var deltaT = canonicalTime - StartTime;

                if ((DockingSubsystem.Connector.WorldMatrix.Translation - (ExpectedPosition + ExpectedVelocity * deltaT.TotalSeconds)).Length() > 80)
                {
                    AutopilotSubsystem.Clear();
                    Status = TaskStatus.Complete;
                }
            }
        }