override protected bool ProcessRequestInternal( RequestCache requestCache, out string result_code) { bool success = true; result_code = SuccessMessages.GENERAL_SUCCESS; success = VerifyGameExists(requestCache, m_game_id, out result_code); if (success) { TypedFlags <eBindGameAction> actionFlags = LookupCharacterData(requestCache); if (actionFlags.Test(eBindGameAction.leaveGame)) { PostCharacterLeftGameEvent(requestCache); LeaveGame(requestCache); } if (actionFlags.Test(eBindGameAction.joinGame)) { PostCharacterJoinedGameEvent(requestCache); JoinGame(requestCache); } } return(success); }
private void UpdateEnergyTankPropVisibility( MobUpdateContext context) { Mob ownerMob = context.mob; NavMesh navMesh = context.moveRequest.Room.runtime_nav_mesh; foreach (EntityProp prop in energy_tank_props) { Point3d oldPropPosition = prop.GetPosition(); // Find the energy tank associated with the player id EnergyTank energyTank = context.moveRequest.EnergyTanks.Find(e => e.ID == prop.target_object_id); // Can the mob see the player at their current location bool canSee = CanMobSeePoint(navMesh, ownerMob, energyTank.Position); TypedFlags <EntityProp.ePropVisibilityFlags> oldVisibilityFlags = new TypedFlags <EntityProp.ePropVisibilityFlags>(prop.visibilityFlags); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.canSee, canSee); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.caughtGlimpse, canSee); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.stationary, true); if (canSee) { // If so, we get to pull the entity properties prop.RefeshEntityProperties(ownerMob, energyTank); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.seenAtLeastOnce, true); } // Update the status of the prop based on the current visibility UpdatePropStatus(ownerMob, prop); // Post an event if we just spotted an energy that we've never seen before if (!oldVisibilityFlags.Test(EntityProp.ePropVisibilityFlags.canSee) && !oldVisibilityFlags.Test(EntityProp.ePropVisibilityFlags.seenAtLeastOnce) && (prop.visibilityFlags.Test(EntityProp.ePropVisibilityFlags.canSee) || prop.visibilityFlags.Test(EntityProp.ePropVisibilityFlags.caughtGlimpse))) { context.output_game_events.Add( new GameEvent_MobEnergyTankPropSpotted() { mob_id = ownerMob.ID, energy_tank_id = prop.target_object_id }); } } }
private void UpdateAIPropVisibility( MobUpdateContext context) { Mob ownerMob = context.mob; NavMesh navMesh = context.moveRequest.Room.runtime_nav_mesh; foreach (EntityProp prop in ai_props) { Point3d oldPropPosition = prop.GetPosition(); // Find the player associated with the player id MobUpdateContext otherMobContext = context.moveRequest.MobContexts.Find(m => m.mob.ID == prop.target_object_id); Mob otherMob = otherMobContext.mob; // Can the mob see the other mob at their current location bool canSee = CanMobSeePoint(navMesh, ownerMob, otherMob.Position); TypedFlags <EntityProp.ePropVisibilityFlags> oldVisibilityFlags = new TypedFlags <EntityProp.ePropVisibilityFlags>(prop.visibilityFlags); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.canSee, canSee); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.caughtGlimpse, canSee); if (canSee) { // If so, we get to pull the entity properties prop.RefeshEntityProperties(ownerMob, otherMob); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.seenAtLeastOnce, true); } else { EntityPath entityPath = otherMobContext.path; if (entityPath != null) { // Find the last place we saw the player along their path, if at all for (int pathStepIndex = entityPath.path.Count - 1; pathStepIndex >= 0; pathStepIndex--) { PathStep pathStep = entityPath.path[pathStepIndex]; if (CanMobSeePoint(navMesh, ownerMob, pathStep.StepPoint)) { prop.position_x = pathStep.StepPoint.x; prop.position_y = pathStep.StepPoint.y; prop.position_z = pathStep.StepPoint.z; prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.caughtGlimpse, true); prop.visibilityFlags.Set(EntityProp.ePropVisibilityFlags.seenAtLeastOnce, true); break; } } } } // Post an event if we just spotted another mob that we've never seen before if (!oldVisibilityFlags.Test(EntityProp.ePropVisibilityFlags.canSee) && !oldVisibilityFlags.Test(EntityProp.ePropVisibilityFlags.seenAtLeastOnce) && (prop.visibilityFlags.Test(EntityProp.ePropVisibilityFlags.canSee) || prop.visibilityFlags.Test(EntityProp.ePropVisibilityFlags.caughtGlimpse))) { context.output_game_events.Add( new GameEvent_MobAIPropSpotted() { mob_id = ownerMob.ID, spotted_mob_id = prop.target_object_id, x = prop.position_x, y = prop.position_y, z = prop.position_z }); } } }
public bool RunTest() { bool success = true; { TypedFlags <TestEnum> flags = new TypedFlags <TestEnum>(); Debug.Assert(flags.IsEmpty()); success &= flags.IsEmpty(); for (TestEnum bitIndex = TestEnum._flag0; bitIndex <= TestEnum._flag31; ++bitIndex) { Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); flags.Set(bitIndex, true); Debug.Assert(flags.Test(bitIndex)); success &= flags.Test(bitIndex); flags.Set(bitIndex, false); Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); } } { TypedFlags <TestEnum> flagsA = new TypedFlags <TestEnum>(); TypedFlags <TestEnum> flagsB = new TypedFlags <TestEnum>(); flagsB.Set(TestEnum._flag10, true); TypedFlags <TestEnum> flagsC = new TypedFlags <TestEnum>(flagsB); Debug.Assert(flagsA != flagsB); success &= flagsA != flagsB; Debug.Assert(flagsB == flagsC); success &= flagsB == flagsC; } { TypedFlags <TestEnum> flags = new TypedFlags <TestEnum>( TypedFlags <TestEnum> .FLAG(TestEnum._flag4) | TypedFlags <TestEnum> .FLAG(TestEnum._flag9)); for (TestEnum bitIndex = TestEnum._flag0; bitIndex <= TestEnum._flag31; ++bitIndex) { if (bitIndex == TestEnum._flag4 || bitIndex == TestEnum._flag9) { Debug.Assert(flags.Test(bitIndex)); success &= flags.Test(bitIndex); } else { Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); } } } return(success); }
public bool RoomHasPortalOnSide(MathConstants.eSignedDirection side) { return(portalRoomSideBitmask.Test(side)); }
public bool RunTest() { bool success = true; { TypedFlags<TestEnum> flags = new TypedFlags<TestEnum>(); Debug.Assert(flags.IsEmpty()); success &= flags.IsEmpty(); for (TestEnum bitIndex = TestEnum._flag0; bitIndex <= TestEnum._flag31; ++bitIndex) { Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); flags.Set(bitIndex, true); Debug.Assert(flags.Test(bitIndex)); success &= flags.Test(bitIndex); flags.Set(bitIndex, false); Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); } } { TypedFlags<TestEnum> flagsA = new TypedFlags<TestEnum>(); TypedFlags<TestEnum> flagsB = new TypedFlags<TestEnum>(); flagsB.Set(TestEnum._flag10, true); TypedFlags<TestEnum> flagsC = new TypedFlags<TestEnum>(flagsB); Debug.Assert(flagsA != flagsB); success &= flagsA != flagsB; Debug.Assert(flagsB == flagsC); success &= flagsB == flagsC; } { TypedFlags<TestEnum> flags = new TypedFlags<TestEnum>( TypedFlags<TestEnum>.FLAG(TestEnum._flag4) | TypedFlags<TestEnum>.FLAG(TestEnum._flag9)); for (TestEnum bitIndex = TestEnum._flag0; bitIndex <= TestEnum._flag31; ++bitIndex) { if (bitIndex == TestEnum._flag4 || bitIndex == TestEnum._flag9) { Debug.Assert(flags.Test(bitIndex)); success &= flags.Test(bitIndex); } else { Debug.Assert(!flags.Test(bitIndex)); success &= !flags.Test(bitIndex); } } } return success; }