Esempio n. 1
0
        public override void Process(SimulationOwnershipChange simulationOwnershipChange)
        {
            foreach (SimulatedEntity simulatedEntity in simulationOwnershipChange.Entities)
            {
                if (multiplayerSession.Reservation.PlayerId == simulatedEntity.PlayerId)
                {
                    if (simulatedEntity.ChangesPosition)
                    {
                        StartBroadcastingEntityPosition(simulatedEntity.Id);
                    }

                    simulationOwnershipManager.SimulateEntity(simulatedEntity.Id, SimulationLockType.TRANSIENT);
                }
                else if (simulationOwnershipManager.HasAnyLockType(simulatedEntity.Id))
                {
                    // The server has forcibly removed this lock from the client.  This is generally fine for
                    // transient locks because it is only broadcasting position.  However, exclusive locks may
                    // need additional cleanup (such as a person piloting a vehicle - they need to be kicked out)
                    // We can later add a forcibly removed callback but as of right now we have no use-cases for
                    // forcibly removing an exclusive lock.  Just log it if it happens....

                    if (simulationOwnershipManager.HasExclusiveLock(simulatedEntity.Id))
                    {
                        Log.Warn("The server has forcibly revoked an exlusive lock - this may cause undefined behaviour.  GUID: " + simulatedEntity.Id);
                    }

                    simulationOwnershipManager.StopSimulatingEntity(simulatedEntity.Id);
                    EntityPositionBroadcaster.StopWatchingEntity(simulatedEntity.Id);
                }
            }
        }
        private void StartBroadcastingEntityPosition(NitroxId id)
        {
            Optional <GameObject> gameObject = NitroxEntity.GetObjectFrom(id);

            if (gameObject.HasValue)
            {
                EntityPositionBroadcaster.WatchEntity(id, gameObject.Value);
            }
            else
            {
                Log.Error("Expected to simulate an unknown entity: " + id);
            }
        }
        private void SimulateEntity(OwnedGuid ownedGuid)
        {
            Optional <GameObject> gameObject = GuidHelper.GetObjectFrom(ownedGuid.Guid);

            if (gameObject.IsPresent())
            {
                EntityPositionBroadcaster.WatchEntity(ownedGuid.Guid, gameObject.Get());
            }
            else
            {
                Log.Error("Expected to simulate an unknown entity: " + ownedGuid.Guid);
            }
        }
        private void StartBroadcastingEntityPosition(string guid)
        {
            Optional <GameObject> gameObject = GuidHelper.GetObjectFrom(guid);

            if (gameObject.IsPresent())
            {
                EntityPositionBroadcaster.WatchEntity(guid, gameObject.Get());
            }
            else
            {
                Log.Error("Expected to simulate an unknown entity: " + guid);
            }
        }
Esempio n. 5
0
        private void StartBroadcastingEntityPosition(NitroxId id)
        {
            Optional <GameObject> gameObject = NitroxEntity.GetObjectFrom(id);

            if (gameObject.HasValue)
            {
                EntityPositionBroadcaster.WatchEntity(id, gameObject.Value);
            }
#if DEBUG && ENTITY_LOG
            else
            {
                Log.Error($"Expected to simulate an unknown entity: {id}");
            }
#endif
        }
        private static void ReceivedSimulationLockResponse(NitroxId id, bool lockAquired, PropulsionGrab context)
        {
            if (lockAquired)
            {
                EntityPositionBroadcaster.WatchEntity(id, context.GrabbedObject);

                skipPrefixPatch = true;
                context.Cannon.GrabObject(context.GrabbedObject);
                skipPrefixPatch = false;
            }
            else
            {
                context.GrabbedObject.AddComponent <DenyOwnershipHand>();
            }
        }