├── LICENSE ├── docs ├── P2P Network.pptx └── Rollback Design.pptx ├── src ├── Pixel3D │ ├── Data2D.cs │ ├── Sprite.cs │ ├── Heightmap.cs │ ├── ColorGradient.cs │ ├── HeightmapView.cs │ ├── ShadowReceiver.cs │ ├── VoxelRenderer.cs │ ├── CombinedHeightmap.cs │ ├── CubeCornerColors.cs │ ├── Animations │ │ ├── Asserts.cs │ │ ├── Animation.cs │ │ ├── AnimationSet.cs │ │ ├── AnimationFrame.cs │ │ ├── AnimationPlayer.cs │ │ ├── ICustomMaskDataReader.cs │ │ ├── FrontBack.cs │ │ ├── Serialization │ │ │ ├── TextureData.cs │ │ │ ├── ITextureLoadHelper.cs │ │ │ ├── ImageKey.cs │ │ │ └── SimpleTextureLoadHelper.cs │ │ ├── ShadowLayer.cs │ │ ├── DepthSlice.cs │ │ └── OutgoingAttachmentView.cs │ ├── IEditorNameProvider.cs │ ├── Physics │ │ ├── WorldPhysics.cs │ │ └── CharacterPhysics.cs │ ├── Sorting │ │ └── DrawOrdering.cs │ ├── Extensions │ │ ├── PointExtensions.cs │ │ ├── ColorDataExtensions.cs │ │ ├── RectangleExtensions.cs │ │ ├── WorldSpriteExtensions.cs │ │ ├── DebugRenderingExtensions.cs │ │ └── PositionExtensions.cs │ ├── FrameworkExtensions │ │ ├── ListExtensions.cs │ │ └── RandomExtensions.cs │ ├── Serialization │ │ └── SerializationExtensions.cs │ ├── IDrawObject.cs │ ├── ISmoothProvider.cs │ ├── HeightmapOpExtensions.cs │ ├── DrawableFrame.cs │ ├── FunctionalTweening │ │ └── FloatMapXNAExtensions.cs │ ├── IHasDrawableFrame.cs │ ├── AnimationSetExtensions.cs │ ├── HeightmapOp.cs │ ├── HeightmapInstructionExtensions.cs │ └── PanCamera.cs ├── Pixel3D.Audio │ ├── Cue.cs │ ├── Sound.cs │ ├── AudioMath.cs │ ├── ListExtensions.cs │ ├── CueDeserializeContext.cs │ ├── CueSerializeContext.cs │ ├── BinaryReadWriteExtensions.cs │ ├── GetMaxPlayers.cs │ ├── AudioRectangle.cs │ ├── IsAudioDeviceAvailable.cs │ ├── GetSingle.cs │ ├── CreateEmptyStreamingAudio.cs │ ├── GetBoolean.cs │ ├── GetString.cs │ ├── ReportMissingCue.cs │ ├── WorldToAudio.cs │ ├── GetTimeSpan.cs │ ├── CreateSoundEffectFromFile.cs │ ├── ReportExpectedCue.cs │ ├── SetBoolean.cs │ ├── SetSingle.cs │ ├── SetString.cs │ ├── GetPlayerAudioPosition.cs │ ├── SetTimeSpan.cs │ ├── PauseSoundEffectInstance.cs │ ├── PlaySoundEffectInstance.cs │ ├── StopSoundEffectInstance.cs │ ├── CreateSoundEffectInstance.cs │ ├── SetFadePitchPan.cs │ ├── CreateSoundEffectFromStream.cs │ ├── PlaySoundEffect.cs │ ├── GetSoundState.cs │ ├── SetState.cs │ ├── AudioSystem.cs │ ├── IAudioDefinitions.cs │ ├── CreateSoundEffectFromVorbisMemory.cs │ ├── PitchPan.cs │ ├── IStreamingAudio.cs │ ├── IAmbientSoundSource.cs │ ├── AmbientSound.cs │ ├── CueType.cs │ ├── IAudioPlayer.cs │ ├── FloatMapExtensions.cs │ ├── AudioDevice.cs │ ├── PlayCueParameters.cs │ └── FadePitchPan.cs ├── Pixel3D.Common │ ├── AABB.cs │ ├── Input.cs │ ├── Log.cs │ ├── TagSet.cs │ ├── InputState.cs │ ├── Position.cs │ ├── TagLookup.cs │ ├── MemoryLogger.cs │ ├── TraceLogger.cs │ ├── LogLineFormatter.cs │ ├── ILogger.cs │ ├── ReferenceEqualityComparer.cs │ ├── BinaryReaderWriterExtensions.cs │ └── MultiInputState.cs ├── Pixel3D.Levels │ ├── Level.cs │ ├── Shim.cs │ ├── IIgnoreParallax.cs │ ├── LevelSerializeContextExtensions.cs │ ├── ISuppressThingWarning.cs │ ├── ILevelEffect.cs │ ├── Path.cs │ ├── ILevelSubBehaviour.cs │ ├── Teleporter.cs │ ├── Region.cs │ └── LevelSubBehaviour.cs ├── Pixel3D.P2P │ ├── P2PServer.cs │ ├── StringFilter.cs │ ├── InputAssignment.cs │ ├── UnconnectedMessage.cs │ ├── IPeerManager.cs │ ├── Pixel3D.P2P.csproj │ ├── P2PClientMessageExtensions.cs │ ├── InsufficientDataToContinueException.cs │ ├── ReadOnlyList.cs │ ├── NetworkDisconnectionException.cs │ ├── NetworkDataException.cs │ ├── P2PServerMessageExtensions.cs │ ├── ProtocolException.cs │ ├── ShutdownWaiter.cs │ ├── P2PServerMessage.cs │ ├── P2PClientMessage.cs │ └── GameInfo.cs ├── CRTSim │ ├── ScreenEffect.cs │ ├── CRTSim.csproj │ ├── IPostProcessor.cs │ ├── IntegerExtensions.cs │ ├── GraphicsDeviceExtensions.cs │ └── Palette.cs ├── Pixel3D.Strings │ ├── ILocalizationProvider.cs │ └── Pixel3D.Strings.csproj ├── Pixel3D.LoopRecorder │ ├── ByteArrayExtensions.cs │ ├── Serialize.cs │ ├── Deserialize.cs │ ├── LoopSystem.cs │ ├── LoopCommand.cs │ └── NaturalStringComparer.cs ├── Pixel3D.Network.Rollback │ ├── RollbackDriver.cs │ ├── PacketTimeTracker.cs │ ├── SynchronisedClock.cs │ ├── InputBuffer.cs │ ├── IAcceptsDesyncDumps.cs │ ├── RollbackNative.cs │ ├── InputStateExtensions.cs │ └── Pixel3D.Network.Rollback.csproj ├── Pixel3D.ActorManagement │ ├── IGameObjectDefinition.cs │ ├── IGameState.cs │ ├── DeferredAttachment.cs │ ├── SmoothingIdentifiers.cs │ ├── Symbols.cs │ ├── AttachmentTracking.cs │ ├── TagSetExtensions.cs │ ├── GameState.cs │ └── Pixel3D.ActorManagement.csproj ├── Pixel3D.Serialization │ ├── BuiltIn │ │ ├── SerializeList.cs │ │ ├── DelegateHandling │ │ │ ├── InvocationList.cs │ │ │ ├── DelegateSerialization.cs │ │ │ ├── DelegateMethodInfo.cs │ │ │ ├── DelegateTypeInfo.cs │ │ │ └── InvocationListEnumerator.cs │ │ ├── SerializeString.cs │ │ ├── SerializeStack.cs │ │ ├── SerializeQueue.cs │ │ └── SerializeStringBuilder.cs │ ├── ReferenceTypeInitializeMethod.cs │ ├── Generator │ │ ├── Direction.cs │ │ ├── MethodCreatorCreator.cs │ │ ├── DeserializeDispatchDelegate.cs │ │ ├── SerializeDispatchDelegate.cs │ │ ├── MethodCreator.cs │ │ ├── DynamicMethodCreatorCreator.cs │ │ ├── DirectionExtensionMethods.cs │ │ ├── DynamicMethodCreator.cs │ │ ├── MethodInfoExtensions.cs │ │ ├── ILWriting │ │ │ └── ILGenContext.cs │ │ ├── MethodBuilderCreatorCreator.cs │ │ └── GeneratorResult.cs │ ├── FieldDeserializeMethod.cs │ ├── CustomSerializerAttribute.cs │ ├── CustomInitializerAttribute.cs │ ├── CustomFieldSerializerAttribute.cs │ ├── ValueTypeSerializeMethod.cs │ ├── ReferenceFieldSerializeMethod.cs │ ├── ReferenceTypeSerializeMethod.cs │ ├── ReferenceTypeDeserializeMethod.cs │ ├── ValueTypeDeserializeMethod.cs │ ├── ReferenceFieldDeserializeMethod.cs │ ├── Static │ │ ├── FieldDeserializerCache.cs │ │ ├── ReferenceTypeSerializerCache.cs │ │ ├── ReferenceTypeDeserializerCache.cs │ │ ├── StaticDelegateTable.cs │ │ ├── FieldSerializerCache.cs │ │ └── StaticModuleTable.cs │ ├── SerializationIgnoreAttribute.cs │ ├── MethodProviders │ │ ├── EmptyMethodProvider.cs │ │ ├── MethodProvider.cs │ │ └── LookupMethodProvider.cs │ ├── SerializableDelegateAttribute.cs │ ├── FieldSerializeMethod.cs │ ├── Discovery │ │ ├── DelegateUsage.cs │ │ ├── ReadIL │ │ │ ├── OpCodeExtensions.cs │ │ │ └── OpCodeValues.cs │ │ └── DelegateUsageInternal.cs │ ├── SerializationIgnoreDelegatesAttribute.cs │ ├── Field.cs │ ├── Context │ │ ├── Constants.cs │ │ └── DefinitionObjectTable.cs │ ├── EnumerableExtensions.cs │ └── SerializationRootAttribute.cs ├── Pixel3D.Serialization.Support │ ├── CustomSerialization.cs │ ├── CustomFieldSerialization.cs │ └── BuiltIn │ │ ├── SerializeIgnoreStateManagement.cs │ │ └── SerializeIgnoreAudio.cs ├── Lidgren.Network │ ├── Documentation │ │ ├── ChangedFromV2.txt │ │ ├── TODO.txt │ │ ├── PacketLayout.txt │ │ └── Improvements.txt │ ├── NetFragmentationInfo.cs │ ├── NamespaceDoc.cs │ ├── SenderChannelBase.cs │ ├── Lidgren.Network.csproj │ ├── NetTuple.cs │ ├── NetStoredReliableMessage.cs │ ├── NetReceiverChannelBase.cs │ ├── Encryption │ │ └── INetEncryption.cs │ ├── NetUnreliableUnorderedReceiver.cs │ ├── NetSenderChannelBase.cs │ ├── NetSendResult.cs │ ├── NetUnreliableSequencedReceiver.cs │ └── NetDeliveryMethod.cs ├── Pixel3D.UI │ ├── TransitionDirection.cs │ ├── ISubMenu.cs │ ├── IAbandonChanges.cs │ ├── IResetToDefaults.cs │ ├── IDrawableGameMenuHost.cs │ └── INetworkSafeContext.cs ├── Pixel3D.Navigation │ ├── NavRegionProjection.cs │ ├── IExcludeInDefaultNav.cs │ ├── PathEdge.cs │ ├── DirectionFlags.cs │ ├── DriveDirection.cs │ ├── MinMax.cs │ └── Pixel3D.Navigation.csproj ├── Pixel3D.Editing │ ├── IntrospectLevelBehaviours.cs │ ├── IntrospectAnimationSetBehaviours.cs │ └── Pixel3D.Editing.csproj ├── Pixel3D.StateManagement │ ├── AlwaysNullCheckedAttribute.cs │ ├── EnumerableExtensions.cs │ └── ReadOnlyList.cs ├── Pixel3D.AssetManagement │ ├── IAssetProvider.cs │ ├── IAssetPathProvider.cs │ ├── AssetDetails.cs │ ├── IHasReferencedAssets.cs │ ├── AssetClassification.cs │ ├── MissingAssetFactory.cs │ └── Pixel3D.AssetManagement.csproj ├── Pixel3D.Network │ ├── FilterName.cs │ ├── SimpleConsoleWriter.cs │ └── NetworkInput.cs ├── Pixel3D.All.XNA │ ├── Engine │ │ └── PlatformSettings.cs │ └── Properties │ │ └── AssemblyInfo.cs └── Pixel3D.Pipeline │ ├── ByteArrayDeduplicator.cs │ ├── MaskDataReferenceResolver.cs │ ├── Pixel3D.Pipeline.csproj │ ├── MaskReadAndDeduplicate.cs │ └── PathGatheringAssetProvider.cs ├── test ├── build │ ├── tools │ │ └── fxc.exe │ └── CopyFNALibs.targets ├── Pixel3D.Network.Demo │ ├── Content │ │ ├── hit.wav │ │ ├── Sprite.png │ │ ├── ready.wav │ │ ├── score.wav │ │ ├── Open_Sans │ │ │ └── OpenSans-Regular.ttf │ │ └── Content.mgcb │ ├── Common │ │ ├── _README.txt │ │ └── BinaryReadWriteXNA.cs │ ├── Effects │ │ └── TestEffect.fx │ ├── Readme.txt │ ├── Program.cs │ └── Pixel3D.Network.Demo.csproj ├── Pixel3D.Serialization.Demo │ ├── app.config │ ├── TestTypes │ │ ├── InheritanceTest.cs │ │ ├── PrimitiveTypes.cs │ │ └── ContainerTypes.cs │ └── Properties │ │ └── AssemblyInfo.cs └── Pixel3D.Network.Test │ ├── Pixel3D.Network.Test.csproj │ └── ConsoleLogHandler.cs ├── .vs └── Pixel3D │ └── v15 │ └── sqlite3 │ └── storage.ide ├── .gitconfig ├── .gitmodules ├── update.cmd ├── Pixel3D.sln.DotSettings └── README.md /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/LICENSE -------------------------------------------------------------------------------- /docs/P2P Network.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/docs/P2P Network.pptx -------------------------------------------------------------------------------- /src/Pixel3D/Data2D.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Data2D.cs -------------------------------------------------------------------------------- /src/Pixel3D/Sprite.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Sprite.cs -------------------------------------------------------------------------------- /src/Pixel3D.Audio/Cue.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/Cue.cs -------------------------------------------------------------------------------- /src/Pixel3D/Heightmap.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Heightmap.cs -------------------------------------------------------------------------------- /test/build/tools/fxc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/build/tools/fxc.exe -------------------------------------------------------------------------------- /docs/Rollback Design.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/docs/Rollback Design.pptx -------------------------------------------------------------------------------- /src/Pixel3D.Audio/Sound.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/Sound.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/AABB.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/AABB.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/Input.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/Input.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/Log.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/Log.cs -------------------------------------------------------------------------------- /src/Pixel3D.Levels/Level.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Levels/Level.cs -------------------------------------------------------------------------------- /src/Pixel3D.Levels/Shim.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Levels/Shim.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/TagSet.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/TagSet.cs -------------------------------------------------------------------------------- /src/Pixel3D.P2P/P2PServer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.P2P/P2PServer.cs -------------------------------------------------------------------------------- /src/Pixel3D/ColorGradient.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/ColorGradient.cs -------------------------------------------------------------------------------- /src/Pixel3D/HeightmapView.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/HeightmapView.cs -------------------------------------------------------------------------------- /src/Pixel3D/ShadowReceiver.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/ShadowReceiver.cs -------------------------------------------------------------------------------- /src/Pixel3D/VoxelRenderer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/VoxelRenderer.cs -------------------------------------------------------------------------------- /src/Pixel3D.Audio/AudioMath.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/AudioMath.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/InputState.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/InputState.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/Position.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/Position.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/TagLookup.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/TagLookup.cs -------------------------------------------------------------------------------- /src/Pixel3D.P2P/StringFilter.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.P2P/StringFilter.cs -------------------------------------------------------------------------------- /src/Pixel3D/CombinedHeightmap.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/CombinedHeightmap.cs -------------------------------------------------------------------------------- /src/Pixel3D/CubeCornerColors.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/CubeCornerColors.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/MemoryLogger.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/MemoryLogger.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/TraceLogger.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/TraceLogger.cs -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Asserts.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Animations/Asserts.cs -------------------------------------------------------------------------------- /src/Pixel3D/IEditorNameProvider.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/IEditorNameProvider.cs -------------------------------------------------------------------------------- /.vs/Pixel3D/v15/sqlite3/storage.ide: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/.vs/Pixel3D/v15/sqlite3/storage.ide -------------------------------------------------------------------------------- /src/CRTSim/ScreenEffect.cs: -------------------------------------------------------------------------------- 1 | namespace CRTSim 2 | { 3 | public enum ScreenEffect 4 | { 5 | None, 6 | CRT, 7 | LCD 8 | } 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/ListExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/ListExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Animation.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Animations/Animation.cs -------------------------------------------------------------------------------- /src/Pixel3D/Physics/WorldPhysics.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Physics/WorldPhysics.cs -------------------------------------------------------------------------------- /src/Pixel3D/Sorting/DrawOrdering.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Sorting/DrawOrdering.cs -------------------------------------------------------------------------------- /src/Pixel3D.Common/LogLineFormatter.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Common/LogLineFormatter.cs -------------------------------------------------------------------------------- /src/Pixel3D/Animations/AnimationSet.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Animations/AnimationSet.cs -------------------------------------------------------------------------------- /src/Pixel3D/Physics/CharacterPhysics.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Physics/CharacterPhysics.cs -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CueDeserializeContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/CueDeserializeContext.cs -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CueSerializeContext.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/CueSerializeContext.cs -------------------------------------------------------------------------------- /src/Pixel3D/Animations/AnimationFrame.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Animations/AnimationFrame.cs -------------------------------------------------------------------------------- /src/Pixel3D/Animations/AnimationPlayer.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Animations/AnimationPlayer.cs -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/PointExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Extensions/PointExtensions.cs -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/hit.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/Pixel3D.Network.Demo/Content/hit.wav -------------------------------------------------------------------------------- /src/Pixel3D.Strings/ILocalizationProvider.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Strings/ILocalizationProvider.cs -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/Sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/Pixel3D.Network.Demo/Content/Sprite.png -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/ready.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/Pixel3D.Network.Demo/Content/ready.wav -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/score.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/Pixel3D.Network.Demo/Content/score.wav -------------------------------------------------------------------------------- /src/Pixel3D.Audio/BinaryReadWriteExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Audio/BinaryReadWriteExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/ByteArrayExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.LoopRecorder/ByteArrayExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/RollbackDriver.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Network.Rollback/RollbackDriver.cs -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/ColorDataExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Extensions/ColorDataExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/RectangleExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Extensions/RectangleExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/WorldSpriteExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Extensions/WorldSpriteExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/PacketTimeTracker.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Network.Rollback/PacketTimeTracker.cs -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/SynchronisedClock.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Network.Rollback/SynchronisedClock.cs -------------------------------------------------------------------------------- /src/Pixel3D/FrameworkExtensions/ListExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/FrameworkExtensions/ListExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/IGameObjectDefinition.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.ActorManagement/IGameObjectDefinition.cs -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/SerializeList.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Serialization/BuiltIn/SerializeList.cs -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/DebugRenderingExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Extensions/DebugRenderingExtensions.cs -------------------------------------------------------------------------------- /src/Pixel3D/Serialization/SerializationExtensions.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D/Serialization/SerializationExtensions.cs -------------------------------------------------------------------------------- /.gitconfig: -------------------------------------------------------------------------------- 1 | # git config --local include.path ../.gitconfig 2 | [filter "tabspace"] 3 | smudge = unexpand --tabs=4 --first-only 4 | clean = expand --tabs=4 --initial -------------------------------------------------------------------------------- /src/Pixel3D.Serialization.Support/CustomSerialization.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Serialization.Support/CustomSerialization.cs -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Common/_README.txt: -------------------------------------------------------------------------------- 1 | These files are copied from `Pixel3D/Common`, to avoid requiring taking a dependency on `Pixel3D` just for the networking layer. -------------------------------------------------------------------------------- /src/Pixel3D.Serialization.Support/CustomFieldSerialization.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Serialization.Support/CustomFieldSerialization.cs -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/Open_Sans/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/test/Pixel3D.Network.Demo/Content/Open_Sans/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/DelegateHandling/InvocationList.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Serialization/BuiltIn/DelegateHandling/InvocationList.cs -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/DelegateHandling/DelegateSerialization.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/conatuscreative/Pixel3D/HEAD/src/Pixel3D.Serialization/BuiltIn/DelegateHandling/DelegateSerialization.cs -------------------------------------------------------------------------------- /test/Pixel3D.Serialization.Demo/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ThirdParty/FNA"] 2 | path = ThirdParty/FNA 3 | url = git@github.com:FNA-XNA/FNA.git 4 | [submodule "ThirdParty/fnalibs"] 5 | path = ThirdParty/fnalibs 6 | url = git@github.com:conatuscreative/fnalibs.git 7 | -------------------------------------------------------------------------------- /src/Lidgren.Network/Documentation/ChangedFromV2.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | * The NetBuffer object is gone; instead there are NetOutgoingMessage and NetIncomingMessage objects 4 | 5 | * No need to allocate a read buffer before calling ReadMessage 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetMaxPlayers.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate int GetMaxPlayers(); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/AudioRectangle.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public struct AudioRectangle 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/IsAudioDeviceAvailable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate bool IsAudioDeviceAvailable(); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/IIgnoreParallax.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.Levels 5 | { 6 | public interface IIgnoreParallax 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.UI/TransitionDirection.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.UI 4 | { 5 | public enum TransitionDirection { RightToLeft, LeftToRight } 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetSingle.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate float GetSingle(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CreateEmptyStreamingAudio.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate IStreamingAudio CreateEmptyStreamingAudio(); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetBoolean.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate bool GetBoolean(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetString.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate string GetString(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/ReportMissingCue.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate void ReportMissingCue(string name, object debugContext); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/WorldToAudio.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate PitchPan WorldToAudio(object owner, int x, int y, int z); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetTimeSpan.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate TimeSpan GetTimeSpan(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CreateSoundEffectFromFile.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate SafeSoundEffect CreateSoundEffectFromFile(string path); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/ReportExpectedCue.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate void ReportExpectedCue(string context, params object[] args); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetBoolean.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void SetBoolean(IDisposable owner, bool value); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetSingle.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void SetSingle(IDisposable owner, float value); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetString.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void SetString(IDisposable owner, string value); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/LevelSerializeContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Levels 4 | { 5 | public static class LevelSerializeContextExtensions 6 | { 7 | } 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetPlayerAudioPosition.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate Position? GetPlayerAudioPosition(object owner, int playerIndex); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetTimeSpan.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void SetTimeSpan(IDisposable owner, TimeSpan value); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/PauseSoundEffectInstance.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void PauseSoundEffectInstance(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/PlaySoundEffectInstance.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void PlaySoundEffectInstance(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/StopSoundEffectInstance.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate void StopSoundEffectInstance(IDisposable owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CreateSoundEffectInstance.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate IDisposable CreateSoundEffectInstance(object owner); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ReferenceTypeInitializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization 4 | { 5 | public delegate T ReferenceTypeInitializeMethod() where T : class; 6 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NetFragmentationInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | public sealed class NetFragmentationInfo 6 | { 7 | public int TotalFragmentCount; 8 | public bool[] Received; 9 | public int TotalReceived; 10 | public int FragmentSize; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetFadePitchPan.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public delegate void SetFadePitchPan(SafeSoundEffectInstance owner, float volume, float pitch, float pan); 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/NavRegionProjection.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Navigation 4 | { 5 | public struct NavRegionProjection 6 | { 7 | public MinMax positive, negative, x, z; 8 | } 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CreateSoundEffectFromStream.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate SafeSoundEffect CreateSoundEffectFromStream(Stream stream); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/PlaySoundEffect.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public delegate bool PlaySoundEffect(IDisposable owner, float volume, float pitch, float pan); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/InputBuffer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.Network.Rollback 5 | { 6 | internal class InputBuffer : FrameDataBuffer 7 | { 8 | // Hi :) 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/GetSoundState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using Microsoft.Xna.Framework.Audio; 5 | 6 | namespace Pixel3D.Audio 7 | { 8 | public delegate SoundState GetSoundState(IDisposable owner); 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/Direction.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Generator 4 | { 5 | internal enum Direction 6 | { 7 | Serialize = 0, 8 | Deserialize = 1 9 | } 10 | } -------------------------------------------------------------------------------- /src/CRTSim/CRTSim.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | AnyCPU;x64 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/SetState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using Microsoft.Xna.Framework.Audio; 5 | 6 | namespace Pixel3D.Audio 7 | { 8 | public delegate void SetState(IDisposable owner, SoundState value); 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Editing/IntrospectLevelBehaviours.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Levels; 4 | 5 | namespace Pixel3D.Editing 6 | { 7 | public class IntrospectLevelBehaviours : IntrospectBehaviours { } 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/ISuppressThingWarning.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Levels 4 | { 5 | public interface ISuppressThingWarning 6 | { 7 | /* Suppress warnings for missing constructors for this type */ 8 | } 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/IExcludeInDefaultNav.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Navigation 4 | { 5 | public interface IExcludeInDefaultNav { /* marks objects that should not be included in default navigation data */ } 6 | } -------------------------------------------------------------------------------- /src/Pixel3D.UI/ISubMenu.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.UI 4 | { 5 | public interface ISubMenu 6 | { 7 | bool IsActive { get; } 8 | void ExitToParentMenu(INetworkSafeContext updateContext); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/ICustomMaskDataReader.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Animations 4 | { 5 | public interface ICustomMaskDataReader 6 | { 7 | uint[] Read(int length); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/Serialize.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | 5 | namespace Pixel3D.LoopRecorder 6 | { 7 | public delegate void Serialize(BinaryWriter bw, ref TGameState gameState, object userData); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Editing/IntrospectAnimationSetBehaviours.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.ActorManagement; 4 | 5 | namespace Pixel3D.Editing 6 | { 7 | public class IntrospectAnimationSetBehaviours : IntrospectBehaviours { } 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/Deserialize.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | 5 | namespace Pixel3D.LoopRecorder 6 | { 7 | public delegate void Deserialize(BinaryReader br, ref TGameState gameState, object userData); 8 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NamespaceDoc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Lidgren.Network 6 | { 7 | /// 8 | /// Lidgren Network Library 9 | /// 10 | internal class NamespaceDoc 11 | { 12 | // 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Lidgren.Network/SenderChannelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal abstract class SenderChannelBase 6 | { 7 | internal abstract NetSendResult Send(float now, NetOutgoingMessage message); 8 | internal abstract void SendQueuedMessages(float now); 9 | internal abstract void Reset(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/IGameState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.ActorManagement 4 | { 5 | public interface IGameState 6 | { 7 | int MaxPlayers { get; } 8 | Position? GetPlayerPosition(int playerIndex); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.UI/IAbandonChanges.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.UI 4 | { 5 | public interface IAbandonChanges 6 | { 7 | bool IsDirty { get; } 8 | void AbandonChanges(); 9 | void PreserveChanges(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Pixel3D.UI/IResetToDefaults.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.UI 4 | { 5 | public interface IResetToDefaults 6 | { 7 | bool IsWaitingToReset { get; set; } 8 | void ResetToDefaults(INetworkSafeContext context); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/AudioSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public static class AudioSystem 6 | { 7 | public static GetMaxPlayers getMaxPlayers; 8 | public static GetPlayerAudioPosition getPlayerAudioPosition; 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/IAudioDefinitions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public interface IAudioDefinitions 6 | { 7 | Cue GetCue(string name, object debugContext); 8 | SafeSoundEffect GetSound(Cue cue, int index); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D/IDrawObject.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Animations; 4 | 5 | namespace Pixel3D 6 | { 7 | public interface IDrawObject 8 | { 9 | void Draw(DrawContext drawContext, int tag, IDrawSmoothProvider sp); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /update.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM use .gitconfig for this repository 4 | git config --local include.path /.gitconfig 5 | 6 | REM first time use 7 | git submodule update --init --recursive 8 | 9 | REM switch all submodules to master 10 | git submodule foreach git checkout master 11 | 12 | REM update all submodules to use tips of master branches 13 | git submodule foreach git pull origin master -------------------------------------------------------------------------------- /src/Lidgren.Network/Lidgren.Network.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | AnyCPU;x64 6 | 7 | 8 | 9 | DEBUG;TRACE 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/CRTSim/IPostProcessor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework.Content; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace CRTSim 5 | { 6 | public interface IPostProcessor 7 | { 8 | GraphicsDevice GraphicsDevice { get; } 9 | ContentManager Content { get; } 10 | void UpdateCameraWindows(); 11 | 12 | int PostProcessingCount { get; } 13 | void SetPostProcessTo(sbyte index); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/LoopSystem.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.LoopRecorder 4 | { 5 | public class LoopSystem 6 | { 7 | public static Serialize serialize; 8 | public static Deserialize deserialize; 9 | } 10 | } -------------------------------------------------------------------------------- /test/Pixel3D.Serialization.Demo/TestTypes/InheritanceTest.cs: -------------------------------------------------------------------------------- 1 | namespace Pixel3D.Serialization.Demo.TestTypes 2 | { 3 | [SerializationRoot] 4 | class BaseClass 5 | { 6 | } 7 | 8 | class DerivedClassA : BaseClass 9 | { 10 | } 11 | 12 | class DerivedClassB : BaseClass 13 | { 14 | } 15 | 16 | class DerivedClassC : DerivedClassA 17 | { 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/CRTSim/IntegerExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace CRTSim 5 | { 6 | internal static class IntegerExtensions 7 | { 8 | /// Clamp a value between min and max, NOTE: Inclusive! 9 | public static int Clamp(this int v, int min, int max) 10 | { 11 | Debug.Assert(min <= max); 12 | return Math.Max(min, Math.Min(max, v)); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.StateManagement/AlwaysNullCheckedAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.StateManagement 6 | { 7 | [AttributeUsage(AttributeTargets.Field)] 8 | public sealed class AlwaysNullCheckedAttribute : Attribute 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CreateSoundEffectFromVorbisMemory.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | public unsafe delegate IDisposable CreateSoundEffectFromVorbisMemory(byte* start, byte* end, int expectedSampleCount, int loopStart, int loopLength); 8 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/FieldDeserializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void FieldDeserializeMethod(DeserializeContext context, BinaryReader br, ref T obj); 9 | } -------------------------------------------------------------------------------- /src/Pixel3D/ISmoothProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D 4 | { 5 | public interface IDrawSmoothProvider 6 | { 7 | Position GetOffset(object owner); 8 | } 9 | 10 | public interface ISortSmoothProvider 11 | { 12 | Position GetOffset(object owner); 13 | } 14 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Test/Pixel3D.Network.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | AnyCPU;x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/DeferredAttachment.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Animations; 4 | 5 | namespace Pixel3D.ActorManagement 6 | { 7 | public struct DeferredAttachment 8 | { 9 | public Actor owner; 10 | public OutgoingAttachment outgoingAttachment; 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/CustomSerializerAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 8 | public sealed class CustomSerializerAttribute : Attribute 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/MethodCreatorCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Generator 4 | { 5 | internal abstract class MethodCreatorCreator // <- yes, I went there. 6 | { 7 | public abstract MethodCreator Create(string containingTypeName); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.UI/IDrawableGameMenuHost.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.UI 4 | { 5 | public interface IDrawableGameMenuHost : IGameMenuHost 6 | { 7 | Position Position { get; } 8 | int Width { get; } 9 | int Height { get; } 10 | bool DeferLayout { get; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/CustomInitializerAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 8 | public sealed class CustomInitializerAttribute : Attribute 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/CustomFieldSerializerAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | [AttributeUsage(AttributeTargets.Method, Inherited = false)] 8 | public sealed class CustomFieldSerializerAttribute : Attribute 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/PitchPan.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public struct PitchPan 6 | { 7 | public float pitch; 8 | public float pan; 9 | 10 | public PitchPan(float pitch, float pan) 11 | { 12 | this.pitch = pitch; 13 | this.pan = pan; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/DeserializeDispatchDelegate.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization.Generator 7 | { 8 | internal delegate object DeserializeDispatchDelegate(DeserializeContext context, BinaryReader br); 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/SerializeDispatchDelegate.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization.Generator 7 | { 8 | internal delegate void SerializeDispatchDelegate(SerializeContext context, BinaryWriter bw, object obj); 9 | } -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/IAssetProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.AssetManagement 6 | { 7 | public interface IAssetProvider 8 | { 9 | T Load(string assetPath) where T : class; 10 | ICollection LoadAll() where T : class; 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/PathEdge.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Navigation 4 | { 5 | public struct PathEdge 6 | { 7 | public int navEdgeIndex; 8 | //public NavRegion region; // <- Commented out: Final path shouldn't need to store this (but we might want to see it for FindPath debug) 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ValueTypeSerializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ValueTypeSerializeMethod(SerializeContext context, BinaryWriter bw, ref T obj) 9 | where T : struct; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ReferenceFieldSerializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ReferenceFieldSerializeMethod(SerializeContext context, BinaryWriter bw, T obj) 9 | where T : class; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ReferenceTypeSerializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ReferenceTypeSerializeMethod(SerializeContext context, BinaryWriter bw, T obj) 9 | where T : class; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ReferenceTypeDeserializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ReferenceTypeDeserializeMethod(DeserializeContext context, BinaryReader br, T obj) 9 | where T : class; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ValueTypeDeserializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ValueTypeDeserializeMethod(DeserializeContext context, BinaryReader br, ref T obj) 9 | where T : struct; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/ReferenceFieldDeserializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | public delegate void ReferenceFieldDeserializeMethod(DeserializeContext context, BinaryReader br, ref T obj) 9 | where T : class; 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/IAssetPathProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.AssetManagement 4 | { 5 | public interface IAssetPathProvider 6 | { 7 | /// Get the path for an asset, or null if the asset is not managed by this provider 8 | string GetAssetPath(T asset) where T : class; 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/InputAssignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | [Flags] 9 | public enum InputAssignment 10 | { 11 | None = 0x0, 12 | 13 | Player1 = 0x1, 14 | Player2 = 0x2, 15 | Player3 = 0x4, 16 | Player4 = 0x8, 17 | 18 | All = 0xF, 19 | Full = All 20 | } 21 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/FieldDeserializerCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Static 4 | { 5 | public static class FieldDeserializerCache 6 | { 7 | public static readonly FieldDeserializeMethod Deserialize = 8 | Serializer.StaticMethodLookup.GetFieldDeserializeDelegate(); 9 | } 10 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Effects/TestEffect.fx: -------------------------------------------------------------------------------- 1 | sampler TextureSampler : register(s0); 2 | 3 | 4 | float4 PixelShaderFunction(float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 5 | { 6 | float4 tex = tex2D(TextureSampler, texCoord); 7 | 8 | return tex * float4(texCoord.x, texCoord.y, 1, 1); 9 | } 10 | 11 | technique Technique1 12 | { 13 | pass Pass1 14 | { 15 | PixelShader = compile ps_2_0 PixelShaderFunction(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Lidgren.Network/NetTuple.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Lidgren.Network 6 | { 7 | // replace with BCL 4.0 Tuple<> when appropriate 8 | internal struct NetTuple 9 | { 10 | public A Item1; 11 | public B Item2; 12 | 13 | public NetTuple(A item1, B item2) 14 | { 15 | Item1 = item1; 16 | Item2 = item2; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/SerializationIgnoreAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | /// The serializer should ignore the field 8 | [AttributeUsage(AttributeTargets.Field)] 9 | public sealed class SerializationIgnoreAttribute : Attribute 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/AssetDetails.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.AssetManagement 4 | { 5 | public class AssetDetails 6 | { 7 | public string FriendlyName { get; set; } 8 | public AssetClassification Classification { get; set; } 9 | public string Path { get; set; } 10 | public object Asset { get; set; } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/MethodCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.Generator 7 | { 8 | internal abstract class MethodCreator 9 | { 10 | public abstract MethodInfo CreateMethod(Type owner, string name, Type returnType, Type[] parameterTypes); 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/IAcceptsDesyncDumps.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.Network.Rollback 5 | { 6 | public interface IAcceptsDesyncDumps 7 | { 8 | void ExportComparativeDesyncDump(byte[] lastGoodSnapshot, byte[] localSnapshot, byte[] remoteSnapshot); 9 | 10 | void ExportSimpleDesyncFrame(byte[] localSnapshot); 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/DynamicMethodCreatorCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Generator 4 | { 5 | internal class DynamicMethodCreatorCreator : MethodCreatorCreator 6 | { 7 | public override MethodCreator Create(string containingTypeName) 8 | { 9 | return new DynamicMethodCreator(); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D/FrameworkExtensions/RandomExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.FrameworkExtensions 6 | { 7 | public static class RandomExtensions 8 | { 9 | public static bool NextBoolean(this Random random) 10 | { 11 | return random.Next(1) != 0; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Lidgren.Network/NetStoredReliableMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal struct NetStoredReliableMessage 6 | { 7 | public int NumSent; 8 | public float LastSent; 9 | public NetOutgoingMessage Message; 10 | public int SequenceNumber; 11 | 12 | public void Reset() 13 | { 14 | NumSent = 0; 15 | LastSent = 0; 16 | Message = null; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/SmoothingIdentifiers.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.ActorManagement 6 | { 7 | public struct SmoothingIdentifiers 8 | { 9 | // Don't need equality check methods because SmoothingManager does the right thing. (And no one will break it, right?) 10 | public Type type; 11 | public int id; 12 | } 13 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/MethodProviders/EmptyMethodProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.MethodProviders 7 | { 8 | internal class EmptyMethodProvider : MethodProvider 9 | { 10 | public override MethodInfo GetMethodForType(Type type) 11 | { 12 | return null; 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/ReferenceTypeSerializerCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Static 4 | { 5 | public static class ReferenceTypeSerializerCache where T : class 6 | { 7 | public static readonly ReferenceTypeSerializeMethod Serialize = 8 | Serializer.StaticMethodLookup.GetReferenceTypeSerializeDelegate(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/IStreamingAudio.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.Audio 5 | { 6 | public interface IStreamingAudio 7 | { 8 | float Volume { get; set; } 9 | bool IsLooped { get; set; } 10 | 11 | unsafe void Open(byte* vorbisStart, byte* vorbisEnd, int loopStart = 0); 12 | void Close(); 13 | 14 | void Play(); 15 | void Pause(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/IAmbientSoundSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | /// 6 | /// Objects that can play back ambient audio 7 | /// 8 | public interface IAmbientSoundSource 9 | { 10 | AmbientSound AmbientSound { get; } 11 | Position Position { get; } 12 | bool FacingLeft { get; } 13 | AABB? Bounds { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/SerializableDelegateAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | /// All delegate types that can be serialized must be tagged with this attribute. 8 | [AttributeUsage(AttributeTargets.Delegate)] 9 | public sealed class SerializableDelegateAttribute : Attribute 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/ReferenceTypeDeserializerCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Static 4 | { 5 | public static class ReferenceTypeDeserializerCache where T : class 6 | { 7 | public static readonly ReferenceTypeDeserializeMethod Deserialize = 8 | Serializer.StaticMethodLookup.GetReferenceTypeDeserializeDelegate(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/StaticDelegateTable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | using Pixel3D.Serialization.BuiltIn.DelegateHandling; 6 | 7 | namespace Pixel3D.Serialization.Static 8 | { 9 | internal static class StaticDelegateTable 10 | { 11 | internal static Dictionary delegateTypeTable; 12 | } 13 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/Documentation/TODO.txt: -------------------------------------------------------------------------------- 1 | 2 | Completed features: 3 | * Message coalescing 4 | * Peer, connection statistics 5 | * Lag, loss and duplication simulation for testing 6 | * Connection approval 7 | * Throttling 8 | * Clock synchronization to detect jitter per packet (NetTime.RemoteNow) 9 | * Peer discovery 10 | * Message fragmentation 11 | 12 | Missing features: 13 | * Receipts 25% done, need design 14 | * More realistic lag/loss (lumpy) 15 | * Detect estimated packet loss 16 | * More advanced ack packet 17 | 18 | -------------------------------------------------------------------------------- /src/Lidgren.Network/Documentation/PacketLayout.txt: -------------------------------------------------------------------------------- 1 | 2 | PER MESSAGE: 3 | 7 bits - NetMessageType 4 | 1 bit - Is a message fragment? 5 | 6 | [8 bits NetMessageLibraryType, if NetMessageType == Library] 7 | 8 | [16 bits sequence number, if NetMessageType >= UserSequenced] 9 | 10 | 8/16 bits - Payload length in bits (variable size ushort) 11 | 12 | [16 bits fragments group id, if fragmented] 13 | [16 bits fragments total count, if fragmented] 14 | [16 bits fragment number, if fragmented] 15 | 16 | [x - Payload] if length > 0 17 | 18 | -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/LoopCommand.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.LoopRecorder 6 | { 7 | [Flags] 8 | public enum LoopCommand : byte 9 | { 10 | None = 0x0, 11 | StartPlaying = 1 << 0, 12 | Stop = 1 << 1, 13 | NextLoop = 1 << 2, 14 | PreviousLoop = 1 << 3, 15 | Record = 1 << 4, 16 | SnapshotOnly = 1 << 5, 17 | RecordHasFocus = 1 << 6 18 | } 19 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NetReceiverChannelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal abstract class NetReceiverChannelBase 6 | { 7 | internal NetPeer m_peer; 8 | internal NetConnection m_connection; 9 | 10 | public NetReceiverChannelBase(NetConnection connection) 11 | { 12 | m_connection = connection; 13 | m_peer = connection.m_peer; 14 | } 15 | 16 | internal abstract void ReceiveMessage(NetIncomingMessage msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/DirectionExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Generator 4 | { 5 | internal static class DirectionExtensionMethods 6 | { 7 | private static readonly string[] names = {"Serialize", "Deserialize"}; 8 | 9 | public static string Name(this Direction direction) 10 | { 11 | return names[(int) direction]; 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/FrontBack.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Animations 4 | { 5 | public struct FrontBack 6 | { 7 | public byte front, back; 8 | 9 | // NOTE: Hacky mechanisim for storing "on top" status without requiring more data (we're nicely 16-bits) 10 | // If we are "on top", then only the back bounds contains usable data 11 | bool IsOnTop { get { return front > back; } } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/ILevelEffect.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using CRTSim; 5 | using Microsoft.Xna.Framework.Graphics; 6 | using Pixel3D.ActorManagement; 7 | 8 | namespace Pixel3D.Levels 9 | { 10 | public interface ILevelEffect 11 | { 12 | void LevelEffect(GameState gameState, RenderTarget2D inputRenderTarget, SpriteBatch sb, FadeEffect fadeEffect, 13 | int fadeLevel, bool disabled); 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/MethodProviders/MethodProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.MethodProviders 7 | { 8 | internal abstract class MethodProvider 9 | { 10 | public MethodInfo this[Type type] 11 | { 12 | get { return GetMethodForType(type); } 13 | } 14 | 15 | public abstract MethodInfo GetMethodForType(Type type); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Serialization/TextureData.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Animations.Serialization 4 | { 5 | public struct TextureData 6 | { 7 | public int width, height; 8 | public byte[] data; 9 | 10 | public TextureData(int width, int height, byte[] data) 11 | { 12 | this.width = width; 13 | this.height = height; 14 | this.data = data; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/Pixel3D.P2P/UnconnectedMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.P2P 5 | { 6 | /// 7 | /// NOTE: a zero-length unconnected message is used for non-responsive NAT punches 8 | /// 9 | internal enum UnconnectedMessage : byte 10 | { 11 | /// This one is used for forming connections between P2P clients. 12 | NATPunchThrough, 13 | 14 | SideChannelVerify, 15 | 16 | SideChannelVerifyResponse 17 | } 18 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/IPeerManager.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Lidgren.Network; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | internal interface IPeerManager 9 | { 10 | /// Handle a network message (it will be recycled externally). 11 | void HandleMessage(NetIncomingMessage message, ref bool recycle); 12 | 13 | void Update(); 14 | 15 | void HandleLocalDisconnection(); 16 | 17 | void KickDueToNetworkDataError(RemotePeer remotePeer); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/FieldSerializeMethod.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization 7 | { 8 | // Field methods that work for both value and reference types (so they can be used successfully in generics) 9 | 10 | public delegate void FieldSerializeMethod(SerializeContext context, BinaryWriter bw, ref T obj); 11 | 12 | // These are the actual method signatures used by the serializer: 13 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/Encryption/INetEncryption.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Lidgren.Network 5 | { 6 | /// 7 | /// Interface for an encryption algorithm 8 | /// 9 | public interface INetEncryption 10 | { 11 | /// 12 | /// Encrypt an outgoing message in place 13 | /// 14 | bool Encrypt(NetOutgoingMessage msg); 15 | 16 | /// 17 | /// Decrypt an incoming message in place 18 | /// 19 | bool Decrypt(NetIncomingMessage msg); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Serialization/ITextureLoadHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Microsoft.Xna.Framework.Graphics; 4 | 5 | namespace Pixel3D.Animations.Serialization 6 | { 7 | public interface ITextureLoadHelper 8 | { 9 | /// Returns a shared load buffer that is big enough to load any texture we might load 10 | byte[] GetSharedLoadBuffer(); 11 | 12 | Texture2D LoadTexture(int width, int height, byte[] buffer); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/DelegateHandling/DelegateMethodInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Reflection; 4 | 5 | namespace Pixel3D.Serialization.BuiltIn.DelegateHandling 6 | { 7 | internal struct DelegateMethodInfo 8 | { 9 | public DelegateMethodInfo(MethodInfo method, bool canHaveTarget) 10 | { 11 | this.method = method; 12 | this.canHaveTarget = canHaveTarget; 13 | } 14 | 15 | public readonly MethodInfo method; 16 | public readonly bool canHaveTarget; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NetUnreliableUnorderedReceiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal sealed class NetUnreliableUnorderedReceiver : NetReceiverChannelBase 6 | { 7 | public NetUnreliableUnorderedReceiver(NetConnection connection) 8 | : base(connection) 9 | { 10 | } 11 | 12 | internal override void ReceiveMessage(NetIncomingMessage msg) 13 | { 14 | // ack no matter what 15 | m_connection.QueueAck(msg.m_receivedMessageType, msg.m_sequenceNumber); 16 | 17 | m_peer.ReleaseMessage(msg); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Discovery/DelegateUsage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.Discovery 7 | { 8 | /// Represents the instantiation of a delegate. 9 | internal struct DelegateUsage 10 | { 11 | /// The static field type of the delegate Target at the instantiation site, or null for no target 12 | public Type targetType; 13 | 14 | public MethodInfo delegateMethod; 15 | public Type delegateType; 16 | } 17 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/SerializationIgnoreDelegatesAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | /// 8 | /// The serializer should ignore any delegates instantiated by this method (the delegates created should never be 9 | /// stored in a serialized field). 10 | /// 11 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor, Inherited = false)] 12 | public sealed class SerializationIgnoreDelegatesAttribute : Attribute 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/Pixel3D.UI/INetworkSafeContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Pixel3D.Audio; 5 | 6 | namespace Pixel3D.UI 7 | { 8 | /// 9 | /// Defines context methods that are safe to call from a networked game. 10 | /// This typically means read-only access, or write operations do not touch the simulation. 11 | /// If the implementation cannot satisfy these requirements, then it should throw. 12 | /// 13 | public interface INetworkSafeContext 14 | { 15 | bool TryGetAudioPlayer(out IAudioPlayer audioPlayer); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Pixel3D/HeightmapOpExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D 4 | { 5 | public static class HeightmapOpExtensions 6 | { 7 | public static bool IsShadowReceiverOperation(this HeightmapOp op) 8 | { 9 | return op == HeightmapOp.CreateExtendedObliqueFromBase || 10 | op == HeightmapOp.ExtendOblique || 11 | op == HeightmapOp.FillLeft || 12 | op == HeightmapOp.FillLeftFixedHeight || 13 | op == HeightmapOp.FillRight || 14 | op == HeightmapOp.FillRightFixedHeight; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/DirectionFlags.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Navigation 6 | { 7 | /// Flags for eight possible directions 8 | [Flags] 9 | public enum DirectionFlags : byte 10 | { 11 | East = (byte) 1u << 0, 12 | NorthEast = (byte) 1u << 1, 13 | North = (byte) 1u << 2, 14 | NorthWest = (byte) 1u << 3, 15 | West = (byte) 1u << 4, 16 | SouthWest = (byte) 1u << 5, 17 | South = (byte) 1u << 6, 18 | SouthEast = (byte) 1u << 7, 19 | 20 | None = 0, 21 | All = 0xFF 22 | } 23 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NetSenderChannelBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal abstract class NetSenderChannelBase 6 | { 7 | // access this directly to queue things in this channel 8 | internal NetQueue m_queuedSends; 9 | 10 | internal abstract int WindowSize { get; } 11 | 12 | internal abstract int GetAllowedSends(); 13 | 14 | internal abstract NetSendResult Enqueue(NetOutgoingMessage message); 15 | internal abstract void SendQueuedMessages(float now); 16 | internal abstract void Reset(); 17 | internal abstract void ReceiveAcknowledge(float now, int sequenceNumber); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/IHasReferencedAssets.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.AssetManagement 6 | { 7 | /// Allows management of assets that reference other assets 8 | public interface IHasReferencedAssets 9 | { 10 | /// Get a list of all assets referenced by this asset 11 | IEnumerable GetReferencedAssets(); 12 | 13 | /// Replace all instances of a given asset with another asset 14 | void ReplaceAsset(object search, object replace); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network/FilterName.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Pixel3D.P2P; 5 | 6 | namespace Pixel3D.Network 7 | { 8 | public static class FilterName 9 | { 10 | // Basically exists to expose this out of Pixel3D.Network.P2P, which Engine doesn't reference 11 | // TODO: Fiddle around with the architecture so that the string filter function is passed up to the network layer 12 | // (Because why does the network know about what characters we can render?) 13 | public static string Filter(string name) 14 | { 15 | return name.FilterName(); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/Pixel3D.LoopRecorder/NaturalStringComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | using System.Security; 6 | 7 | namespace Pixel3D.LoopRecorder 8 | { 9 | public sealed class NaturalStringComparer : IComparer 10 | { 11 | public int Compare(string a, string b) 12 | { 13 | return StrCmpLogicalW(a, b); 14 | } 15 | 16 | [DllImport("shlwapi.dll", CharSet = CharSet.Unicode)] 17 | [SuppressUnmanagedCodeSecurity] 18 | private static extern int StrCmpLogicalW(string psz1, string psz2); 19 | } 20 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/Path.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.Levels 6 | { 7 | public class Path 8 | { 9 | /// Arbitrary level properties (consumers are expected to parse the strings) 10 | public readonly OrderedDictionary properties = new OrderedDictionary(); 11 | 12 | public bool looped; 13 | 14 | public List positions = new List(); 15 | 16 | // Provided to allow parameterless construction (due to presence of deserialization constructor) 17 | } 18 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/AmbientSound.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | // TODO: Replace me with Cue 6 | public class AmbientSound 7 | { 8 | public readonly float pan; 9 | public readonly float pitch; 10 | public readonly float volume; 11 | public int radius; 12 | public SafeSoundEffect soundEffect; 13 | 14 | public AmbientSound(SafeSoundEffect sound, int radius, float volume, float pitch, float pan) 15 | { 16 | soundEffect = sound; 17 | this.radius = radius; 18 | this.volume = volume; 19 | this.pitch = pitch; 20 | this.pan = pan; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/Pixel3D.P2P.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | AnyCPU;x64 6 | 7 | 8 | 9 | DEBUG;TRACE 10 | 11 | 12 | 13 | DEBUG;TRACE 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Pixel3D/DrawableFrame.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Animations; 4 | 5 | namespace Pixel3D 6 | { 7 | // NOTE: This is basically for debug views 8 | public struct DrawableFrame 9 | { 10 | public DrawableFrame(AnimationFrame animationFrame, Position position, bool flipX) 11 | { 12 | this.animationFrame = animationFrame; 13 | this.position = position; 14 | this.flipX = flipX; 15 | } 16 | 17 | public AnimationFrame animationFrame; 18 | public Position position; 19 | public bool flipX; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Field.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | using Pixel3D.Serialization.Static; 6 | 7 | namespace Pixel3D.Serialization 8 | { 9 | public static class Field 10 | { 11 | public static void Serialize(SerializeContext context, BinaryWriter bw, ref T obj) 12 | { 13 | FieldSerializerCache.Serialize(context, bw, ref obj); 14 | } 15 | 16 | public static void Deserialize(DeserializeContext context, BinaryReader br, ref T obj) 17 | { 18 | FieldDeserializerCache.Deserialize(context, br, ref obj); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/P2PClientMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Lidgren.Network; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | internal static class P2PClientMessageExtensions 9 | { 10 | public static void Write(this NetOutgoingMessage message, P2PClientMessage m) 11 | { 12 | message.Write((byte) m); 13 | } 14 | 15 | public static P2PClientMessage TryReadP2PClientMessage(this NetIncomingMessage message) 16 | { 17 | try 18 | { 19 | return (P2PClientMessage) message.ReadByte(); 20 | } 21 | catch 22 | { 23 | return P2PClientMessage.Unknown; 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Pixel3D/FunctionalTweening/FloatMapXNAExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Microsoft.Xna.Framework; 4 | 5 | namespace Pixel3D.FunctionalTweening 6 | { 7 | public static class FloatMapXNAExtensions 8 | { 9 | /// Map a float between two colours 10 | public static Color MapTo(this float value, Color zero, Color one) 11 | { 12 | return Color.Lerp(zero, one, value); 13 | } 14 | 15 | /// Map a float between two Vector2s 16 | public static Vector2 MapTo(this float value, Vector2 zero, Vector2 one) 17 | { 18 | return Vector2.Lerp(zero, one, value); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/CueType.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | /// 6 | /// Parallel: all sounds in the cue play at the same time 7 | /// Serial: all sounds play one after the other 8 | /// Cycle: first cue plays sound1, second cue plays sound2, repeating etc. 9 | /// Random: each cue plays randomly one of the sounds in it 10 | /// RandomCycle: each cue plays randomly but does not replay a sound until all other sounds have been played 11 | /// 12 | public enum CueType : byte 13 | { 14 | Parallel, 15 | Serial, 16 | Cycle, 17 | Random, 18 | RandomCycle 19 | } 20 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Readme.txt: -------------------------------------------------------------------------------- 1 | Requires the following system installs: 2 | - DirectX SDL (June 2010) on Windows 3 | - Wine with `winetricks d3dcompiler_43` on OSX 4 | - MonoGame 3.6 (or newer?) on both Windows and OSX 5 | 6 | Requires the following directories to be added at the same level as the Solution 7 | - "FNA" containing FNA project from https://github.com/FNA-XNA/FNA 8 | - "FNALibs" containing FNA libraries from http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 9 | 10 | Note the Build Actions (see "Import"s in the .csproj) 11 | - MonoGameContentBuild 12 | - CompileShader 13 | 14 | Note that shaders need to be loaded from fxb files, not through ContentManager (example is provided) 15 | 16 | Should work on both VS2010 (and probably newer) and VS Mac 2017 17 | 18 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/Symbols.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.ActorManagement 4 | { 5 | public static class Symbols 6 | { 7 | public static readonly string Left = "Left"; 8 | public static readonly string Right = "Right"; 9 | public static readonly string Up = "Up"; 10 | public static readonly string Down = "Down"; 11 | public static readonly string Front = "Front"; 12 | public static readonly string Back = "Back"; 13 | 14 | public static readonly string Default = "Default"; 15 | public static readonly string DefaultSpawn = "Spawn"; 16 | public static readonly string SubBehaviours = "SubBehaviours"; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/DriveDirection.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Navigation 6 | { 7 | // Packing two signed 2-bit numbers (X in low, Z in high) 8 | // Using 2 bits as it allows minimal jump tables while retaining simple unpack behaviour 9 | [Flags] // <- ... or something to that effect 10 | public enum DriveDirection : byte 11 | { 12 | None = 0, 13 | 14 | East = 1, // 0b01 = 1 15 | West = 3, // 0b11 = -1 16 | North = East << 2, 17 | South = West << 2, 18 | 19 | NorthEast = North | East, 20 | NorthWest = North | West, 21 | SouthEast = South | East, 22 | SouthWest = South | West 23 | } 24 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/ShadowLayer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Diagnostics; 4 | 5 | namespace Pixel3D.Animations 6 | { 7 | [DebuggerDisplay("Shadow from height = {startHeight}")] 8 | public struct ShadowLayer 9 | { 10 | public ShadowLayer(int startHeight, SpriteRef shadowSpriteRef) 11 | { 12 | this.startHeight = startHeight; 13 | this.shadowSpriteRef = shadowSpriteRef; 14 | } 15 | 16 | /// The minimum (inclusive) height where this shadow sprite gets used 17 | public int startHeight; 18 | public SpriteRef shadowSpriteRef; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Context/Constants.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Context 4 | { 5 | internal static class Constants 6 | { 7 | internal const int DefinitionSerializationId = -1; 8 | 9 | // Visited object table index flat format: 10 | // 0xFFFFFFFF = null 11 | // 0xFFFFFFFE = first visit (read into object) 12 | // 0x00000000+ = index into visited object table 13 | // 0x80000000+ = index into definition object table (mask out high bit) 14 | internal const uint DefinitionVisitFlag = 1u << 31; 15 | internal const uint VisitNull = uint.MaxValue; 16 | internal const uint FirstVisit = uint.MaxValue - 1; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network/SimpleConsoleWriter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Microsoft.Xna.Framework; 5 | using Pixel3D.P2P.Diagnostics; 6 | 7 | namespace Pixel3D.Network 8 | { 9 | public class SimpleConsoleWriter : NetworkLogHandler 10 | { 11 | private readonly SimpleConsole target; 12 | 13 | public SimpleConsoleWriter(SimpleConsole target) 14 | { 15 | this.target = target; 16 | } 17 | 18 | public override void HandleLidgrenMessage(string message) 19 | { 20 | target.WriteLine(message, Color.DarkBlue); 21 | } 22 | 23 | public override void HandleMessage(string message) 24 | { 25 | target.WriteLine(message, Color.DarkGreen); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Pixel3D.Common/ILogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D 6 | { 7 | public interface ILogger 8 | { 9 | void Trace(string message, params object[] args); 10 | void Info(string message, params object[] args); 11 | void Warn(string message, params object[] args); 12 | void Error(string message, params object[] args); 13 | void Fatal(string message, params object[] args); 14 | 15 | void WarnException(string message, Exception exception, params object[] args); 16 | void ErrorException(string message, Exception exception, params object[] args); 17 | void FatalException(string message, Exception exception, params object[] args); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/DynamicMethodCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | using System.Reflection.Emit; 6 | 7 | namespace Pixel3D.Serialization.Generator 8 | { 9 | internal class DynamicMethodCreator : MethodCreator 10 | { 11 | public override MethodInfo CreateMethod(Type owner, string name, Type returnType, Type[] parameterTypes) 12 | { 13 | if (owner != null && owner.IsInterface) 14 | owner = null; 15 | if (owner == null || owner.IsArray) 16 | return new DynamicMethod(name, returnType, parameterTypes, true); 17 | return new DynamicMethod(name, returnType, parameterTypes, owner, true); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/NetSendResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | /// 6 | /// Result of a SendMessage call 7 | /// 8 | public enum NetSendResult 9 | { 10 | /// 11 | /// Message failed to enqueue because there is no connection 12 | /// 13 | FailedNotConnected = 0, 14 | 15 | /// 16 | /// Message was immediately sent 17 | /// 18 | Sent = 1, 19 | 20 | /// 21 | /// Message was queued for delivery 22 | /// 23 | Queued = 2, 24 | 25 | /// 26 | /// Message was dropped immediately since too many message were queued 27 | /// 28 | Dropped = 3 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/RollbackNative.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace Pixel3D.Network.Rollback 8 | { 9 | internal static class RollbackNative 10 | { 11 | [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] 12 | private static extern int memcmp(byte[] data1, byte[] data2, UIntPtr bytes); 13 | 14 | /// True if the buffers are the same 15 | public static bool CompareBuffers(byte[] buffer1, byte[] buffer2) 16 | { 17 | if (buffer1.Length != buffer2.Length) 18 | return false; 19 | 20 | return memcmp(buffer1, buffer2, (UIntPtr) buffer1.Length) == 0; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Pixel3D.All.XNA/Engine/PlatformSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.IO; 6 | 7 | namespace Pixel3D.Engine 8 | { 9 | public static class PlatformSettings 10 | { 11 | public static string GetPlatformSettingsDir(string gameTitlePath) 12 | { 13 | return @"."; 14 | } 15 | 16 | public static string CreateAndReturnDir(string dir) 17 | { 18 | if (!Directory.Exists(dir)) 19 | { 20 | Directory.CreateDirectory(dir); 21 | } 22 | 23 | return dir; 24 | } 25 | 26 | public static string GetLoggingDir() 27 | { 28 | return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Conatus Creative", "RCRU"); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Pixel3D/IHasDrawableFrame.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D 4 | { 5 | // TODO BUG: Pretty much everything that is using this is disregarding the fact that an item may be in the draw list multiple times 6 | // with different "tag" for drawing differently. Relates to following todo item... 7 | 8 | // TODO: This should probably be replaced with a mechanisim that actually captures what gets drawn to the screen 9 | // (at least for in-engine debugging) 10 | public interface IHasDrawableFrame 11 | { 12 | /// Get a frame to draw for this item for debugging/editing purposes 13 | DrawableFrame GetDrawableFrame(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/FieldSerializerCache.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Static 4 | { 5 | // These classes offload the caching of serialization methods onto the CLR 6 | // (They will be filled when the CLR JITs any method that references them) 7 | // 8 | // IMPORTANT: Do not add static constructors to these types, as this will remove their "beforefieldinit" flag 9 | // (which, in turn, will cause an initialization check to occur every time they are accessed) 10 | 11 | public static class FieldSerializerCache 12 | { 13 | public static readonly FieldSerializeMethod Serialize = 14 | Serializer.StaticMethodLookup.GetFieldSerializeDelegate(); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace Pixel3D.Serialization 8 | { 9 | public static class EnumerableExtensions 10 | { 11 | /// 12 | /// Sort a given enumeration in a fixed order, required for anything sent over the network in a fixed order 13 | /// (eg: object fields in generated serializers) or by an assigned ID number (eg: dynamic type dispatch). 14 | /// 15 | public static IEnumerable NetworkOrder(this IEnumerable enumerator, Func getName) 16 | { 17 | return enumerator.OrderBy(getName, StringComparer.Ordinal); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Static/StaticModuleTable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.Static 7 | { 8 | internal class StaticModuleTable 9 | { 10 | internal static Dictionary moduleToId; 11 | internal static List idToModule; 12 | 13 | /// A list of modules that is sorted by a reproducible sort (order is network-sensitive) 14 | internal static void SetModuleTable(List modules) 15 | { 16 | moduleToId = new Dictionary(); 17 | idToModule = modules; 18 | 19 | for (var i = 0; i < modules.Count; i++) moduleToId.Add(modules[i], i); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Pixel3D.StateManagement/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | 7 | namespace Pixel3D.StateManagement 8 | { 9 | internal static class EnumerableExtensions 10 | { 11 | /// 12 | /// Sort a given enumeration in a fixed order, required for anything sent over the network in a fixed order 13 | /// (eg: object fields in generated serializers) or by an assigned ID number (eg: dynamic type dispatch). 14 | /// 15 | public static IEnumerable NetworkOrder(this IEnumerable enumerator, Func getName) 16 | { 17 | return enumerator.OrderBy(getName, StringComparer.Ordinal); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Pixel3D.sln.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | Copyright © Conatus Creative, Inc. All rights reserved. 3 | Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 4 | 5 | AABB 6 | <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/AssetClassification.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.AssetManagement 4 | { 5 | public enum AssetClassification 6 | { 7 | /// Asset is embedded (not managed) 8 | Embedded, 9 | 10 | /// Asset is managed 11 | Managed, 12 | 13 | /// Asset is managed, but is outside the given asset root directory 14 | OutOfPath, 15 | 16 | /// Asset is managed, but has an unexpected extension 17 | BadExtension, 18 | 19 | /// 20 | /// Asset could not be found at load time (and is being represented by a fake "missing" asset that retains path 21 | /// info.) 22 | /// 23 | Missing 24 | } 25 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace Pixel3D.Network.Demo 6 | { 7 | class Program 8 | { 9 | [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] 10 | [return: MarshalAs(UnmanagedType.Bool)] 11 | static extern bool SetDllDirectory(string lpPathName); 12 | 13 | static void Main(string[] args) 14 | { 15 | // https://github.com/FNA-XNA/FNA/wiki/4:-FNA-and-Windows-API#64-bit-support 16 | if(Environment.OSVersion.Platform == PlatformID.Win32NT) 17 | { 18 | SetDllDirectory(Path.Combine( 19 | AppDomain.CurrentDomain.BaseDirectory, 20 | Environment.Is64BitProcess ? "x64" : "x86" 21 | )); 22 | } 23 | 24 | using(NetworkDemoGame game = new NetworkDemoGame()) 25 | { 26 | game.Run(); 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/IAudioPlayer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | public interface IAudioPlayer 6 | { 7 | /// Play a sound without any position (always plays centered) 8 | void PlayCueGlobal(string symbol, 9 | object source = 10 | null); // <- keeping source around, in case it is useful information (will become useful for rollback) 11 | 12 | /// Play a sound without any position (always plays centered) 13 | void PlayCueGlobal(Cue cue, 14 | object source = 15 | null); // <- keeping source around, in case it is useful information (will become useful for rollback) 16 | 17 | void PlayMenuMusic(string symbol, bool loop = true, bool synchronise = false); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/InsufficientDataToContinueException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Pixel3D.P2P 8 | { 9 | [Serializable] 10 | public class InsufficientDataToContinueException : Exception 11 | { 12 | public InsufficientDataToContinueException() 13 | { 14 | } 15 | 16 | public InsufficientDataToContinueException(string message) : base(message) 17 | { 18 | } 19 | 20 | public InsufficientDataToContinueException(string message, Exception inner) : base(message, inner) 21 | { 22 | } 23 | 24 | protected InsufficientDataToContinueException( 25 | SerializationInfo info, 26 | StreamingContext context) 27 | : base(info, context) 28 | { 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Context/DefinitionObjectTable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.Serialization.Context 6 | { 7 | public class DefinitionObjectTable 8 | { 9 | internal Dictionary externalVisitedObjectIndices; 10 | 11 | internal List visitedObjectTable; 12 | 13 | internal DefinitionObjectTable(List visitedObjectTable, 14 | Dictionary externalVisitedObjectIndices) 15 | { 16 | this.visitedObjectTable = visitedObjectTable; 17 | this.externalVisitedObjectIndices = externalVisitedObjectIndices; 18 | } 19 | 20 | public bool ContainsObject(object o) 21 | { 22 | return externalVisitedObjectIndices.ContainsKey(o); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/ReadOnlyList.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System.Collections.Generic; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | /// Thin wrapper around List that, unlike ReadOnlyCollection, does not allocate. 9 | /// Could implement IList... but that just invites boxing. 10 | public struct ReadOnlyList 11 | { 12 | private readonly List list; 13 | 14 | public ReadOnlyList(List list) 15 | { 16 | this.list = list; 17 | } 18 | 19 | public int Count => list.Count; 20 | public T this[int index] => list[index]; 21 | 22 | // List already has a perfectly serviceable non-allocating enumerator: 23 | public List.Enumerator GetEnumerator() 24 | { 25 | return list.GetEnumerator(); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Pixel3D/AnimationSetExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Animations; 4 | 5 | namespace Pixel3D 6 | { 7 | public static class AnimationSetExtensions 8 | { 9 | public static AABB AsAABB(this AnimationSet animationSet, Position position, bool facingLeft) 10 | { 11 | // TODO: Stop assuming a height, and get a real AABB from the heightmap (requires Heightmap cache its own AABB) 12 | var heightmapView = new HeightmapView(animationSet.Heightmap, position, facingLeft); 13 | var heightmapXZ = heightmapView.Bounds; 14 | const int guessHeight = 50; 15 | var aabb = new AABB(heightmapXZ.Left, heightmapXZ.Right - 1, position.Y, position.Y + guessHeight, heightmapXZ.Y, heightmapXZ.Y + heightmapXZ.Height - 1); 16 | return aabb; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Pixel3D.Common/ReferenceEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Runtime.CompilerServices; 5 | 6 | namespace Pixel3D 7 | { 8 | public class ReferenceEqualityComparer : IEqualityComparer where T : class 9 | { 10 | static ReferenceEqualityComparer() 11 | { 12 | Instance = new ReferenceEqualityComparer(); 13 | } 14 | 15 | private ReferenceEqualityComparer() 16 | { 17 | } // <- no external instancing 18 | 19 | public static ReferenceEqualityComparer Instance { get; private set; } 20 | 21 | public bool Equals(T x, T y) 22 | { 23 | return ReferenceEquals(x, y); 24 | } 25 | 26 | public int GetHashCode(T obj) 27 | { 28 | return RuntimeHelpers.GetHashCode(obj); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/NetworkDisconnectionException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Pixel3D.P2P 8 | { 9 | /// 10 | /// Thrown when the network gets disconnected 11 | /// 12 | [Serializable] 13 | public class NetworkDisconnectionException : Exception 14 | { 15 | public NetworkDisconnectionException() 16 | { 17 | } 18 | 19 | public NetworkDisconnectionException(string message) : base(message) 20 | { 21 | } 22 | 23 | public NetworkDisconnectionException(string message, Exception inner) : base(message, inner) 24 | { 25 | } 26 | 27 | protected NetworkDisconnectionException( 28 | SerializationInfo info, 29 | StreamingContext context) 30 | : base(info, context) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/FloatMapExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Audio 4 | { 5 | internal static class FloatMapExtensions 6 | { 7 | #region Functions 8 | 9 | /// Returns a value clamped between 0 and 1 10 | public static float Clamp(this float value) 11 | { 12 | if (value < 0f) return 0f; 13 | if (value > 1f) return 1f; 14 | return value; 15 | } 16 | 17 | #endregion 18 | 19 | #region Mapping 20 | 21 | public static float MapFrom(this float value, float min, float max) 22 | { 23 | var position = value - min; 24 | var scale = max - min; 25 | return position / scale; 26 | } 27 | 28 | public static float MapTo(this float value, float min, float max) 29 | { 30 | return min + (max - min) * value; 31 | } 32 | 33 | #endregion 34 | } 35 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/InputStateExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System.Diagnostics; 5 | using Lidgren.Network; 6 | 7 | namespace Pixel3D.Network.Rollback 8 | { 9 | internal static class InputStateExtensions 10 | { 11 | #region Network Read/Write 12 | 13 | public static void WriteInputState(this NetOutgoingMessage message, InputState inputState, int bits) 14 | { 15 | // If this assert triggers, you've specified too few bits to use for inputs 16 | Debug.Assert(((uint) inputState & ((1u << bits) - 1u)) == (uint) inputState); 17 | 18 | message.Write((uint) inputState, bits); 19 | } 20 | 21 | public static InputState ReadInputState(this NetIncomingMessage message, int bits) 22 | { 23 | return (InputState) message.ReadUInt32(bits); 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /test/build/CopyFNALibs.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | x86\%(RecursiveDir)%(Filename)%(Extension) 7 | PreserveNewest 8 | 9 | 10 | x64\%(RecursiveDir)%(Filename)%(Extension) 11 | PreserveNewest 12 | 13 | 14 | osx\%(RecursiveDir)%(Filename)%(Extension) 15 | PreserveNewest 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Lidgren.Network/NetUnreliableSequencedReceiver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Lidgren.Network 4 | { 5 | internal sealed class NetUnreliableSequencedReceiver : NetReceiverChannelBase 6 | { 7 | private int m_lastReceivedSequenceNumber; 8 | 9 | public NetUnreliableSequencedReceiver(NetConnection connection) 10 | : base(connection) 11 | { 12 | } 13 | 14 | internal override void ReceiveMessage(NetIncomingMessage msg) 15 | { 16 | int nr = msg.m_sequenceNumber; 17 | 18 | // ack no matter what 19 | m_connection.QueueAck(msg.m_receivedMessageType, nr); 20 | 21 | int relate = NetUtility.RelativeSequenceNumber(nr, m_lastReceivedSequenceNumber); 22 | if (relate < 0) 23 | return; // drop if late 24 | 25 | m_lastReceivedSequenceNumber = nr; 26 | m_peer.ReleaseMessage(msg); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/MethodInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Reflection; 5 | using System.Reflection.Emit; 6 | 7 | namespace Pixel3D.Serialization.Generator 8 | { 9 | internal static class MethodInfoExtensions 10 | { 11 | // Let's pretend that MethodInfo provides GetILGenerator as an abstract method... 12 | public static ILGenerator GetILGenerator(this MethodInfo methodInfo) 13 | { 14 | var dynamicMethod = methodInfo as DynamicMethod; 15 | if (dynamicMethod != null) 16 | return dynamicMethod.GetILGenerator(); 17 | 18 | var methodBuilder = methodInfo as MethodBuilder; 19 | if (methodBuilder != null) 20 | return methodBuilder.GetILGenerator(); 21 | 22 | throw new InvalidOperationException("Cannot generate IL for fixed MethodInfo"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network.Rollback/Pixel3D.Network.Rollback.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | AnyCPU;x64 7 | 8 | 9 | 10 | DEBUG;TRACE 11 | 12 | 13 | 14 | DEBUG;TRACE 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Pixel3D/HeightmapOp.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D 4 | { 5 | /// Heightmap operations (these match methods in Heightmap) 6 | /// Values are serialization sensitive! 7 | public enum HeightmapOp 8 | { 9 | ClearToHeight = 0, 10 | SetFromFlatBaseMask = 1, 11 | SetFromFlatTopMask = 2, 12 | SetFromObliqueTopMask = 3, 13 | SetFromRailingMask = 4, 14 | SetFromFrontEdge = 5, 15 | SetFlatRelative = 12, // New in version 8 16 | SetFromSideOblique = 13, // New in version 9 17 | 18 | // ShadowReceiver-related instructions: 19 | 20 | /// For ShadowReceiver, creates from the AnimationSet heightmap 21 | CreateExtendedObliqueFromBase = 6, 22 | ExtendOblique = 7, 23 | FillLeft = 8, 24 | FillLeftFixedHeight = 9, 25 | FillRight = 10, 26 | FillRightFixedHeight = 11, 27 | } 28 | } -------------------------------------------------------------------------------- /test/Pixel3D.Serialization.Demo/TestTypes/PrimitiveTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Pixel3D.Serialization.Demo.TestTypes 4 | { 5 | #pragma warning disable 649 // "Never assigned" (ok - testing reflection) 6 | 7 | [SerializationRoot] 8 | struct PrimitiveTypes 9 | { 10 | public int @int; 11 | public uint @uint; 12 | public short @short; 13 | public ushort @ushort; 14 | public sbyte @sbyte; 15 | public byte @byte; 16 | public float @float; 17 | public double @double; 18 | public ulong @ulong; 19 | public long @long; 20 | public char @char; 21 | public bool @bool; 22 | 23 | // Ignored by the serializer: 24 | public IntPtr intPtr; 25 | public UIntPtr uintPtr; 26 | public object @object; // (technically not primitive) 27 | 28 | // Handled by built-in field serializer: 29 | public string @string; // (technically not primitive) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/SerializeString.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Pixel3D.Serialization.Context; 5 | 6 | namespace Pixel3D.Serialization.BuiltIn 7 | { 8 | internal static class SerializeString 9 | { 10 | [CustomFieldSerializer] 11 | public static void SerializeField(SerializeContext context, BinaryWriter bw, string value) 12 | { 13 | if (context.WalkString(value) == null) // null check 14 | return; 15 | 16 | context.VisitObject(value); 17 | bw.Write(value); 18 | context.LeaveObject(); 19 | } 20 | 21 | [CustomFieldSerializer] 22 | public static void DeserializeField(DeserializeContext context, BinaryReader br, ref string value) 23 | { 24 | if (!context.Walk(ref value)) 25 | return; 26 | 27 | value = br.ReadString(); // TODO: one day we might like to not allocate here. 28 | context.VisitObject(value); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Pixel3D.StateManagement/ReadOnlyList.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.StateManagement 6 | { 7 | /// Thin wrapper around List that, unlike ReadOnlyCollection, does not allocate. 8 | /// Could implement IList... but that just invites boxing. 9 | public struct ReadOnlyList 10 | { 11 | private readonly List list; 12 | 13 | public ReadOnlyList(List list) 14 | { 15 | this.list = list; 16 | } 17 | 18 | public int Count 19 | { 20 | get { return list.Count; } 21 | } 22 | 23 | public T this[int index] 24 | { 25 | get { return list[index]; } 26 | } 27 | 28 | // List already has a perfectly serviceable non-allocating enumerator: 29 | public List.Enumerator GetEnumerator() 30 | { 31 | return list.GetEnumerator(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Pixel3D.Pipeline/ByteArrayDeduplicator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.Pipeline 6 | { 7 | public class ByteArrayDeduplicator 8 | { 9 | public readonly List arrays = new List(); 10 | public readonly Dictionary indicies = new Dictionary(); 11 | 12 | private int rawBytes, dedupBytes, rawCount, dedupCount; 13 | 14 | public int Add(byte[] originalData) 15 | { 16 | rawBytes += originalData.Length; 17 | rawCount++; 18 | 19 | int index; 20 | var comparableData = new ComparableByteArray(originalData); 21 | if (!indicies.TryGetValue(comparableData, out index)) 22 | { 23 | index = arrays.Count; 24 | indicies.Add(comparableData, index); 25 | arrays.Add(originalData); 26 | 27 | dedupBytes += originalData.Length; 28 | dedupCount++; 29 | } 30 | 31 | return index; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Discovery/ReadIL/OpCodeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Reflection.Emit; 4 | 5 | namespace Pixel3D.Serialization.Discovery.ReadIL 6 | { 7 | internal static class OpCodeExtensions 8 | { 9 | // Improve check performance by comparing to hard-coded opcode values: 10 | // (because CLR equality check for OpCode is very much sub-optimal) 11 | 12 | public static bool IsLdarg(this OpCode opCode) 13 | { 14 | var value = (ushort) opCode.Value; 15 | return value >= OpCodeValues.Ldarg_0 && value <= OpCodeValues.Ldarg_3 16 | || value == OpCodeValues.Ldarg_S 17 | || value == OpCodeValues.Ldarg; 18 | } 19 | 20 | public static bool IsLdloc(this OpCode opCode) 21 | { 22 | var value = (ushort) opCode.Value; 23 | return value >= OpCodeValues.Ldloc_0 && value <= OpCodeValues.Ldloc_3 24 | || value == OpCodeValues.Ldloc_S 25 | || value == OpCodeValues.Ldloc; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/ILevelSubBehaviour.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.ActorManagement; 4 | using Pixel3D.Animations; 5 | 6 | namespace Pixel3D.Levels 7 | { 8 | public interface IGlobalLevelSubBehaviour { } 9 | 10 | public interface ILevelSubBehaviour 11 | { 12 | void BeforeBeginLevel(UpdateContext updateContext); 13 | void BeginLevelStoryTriggers(UpdateContext updateContext); 14 | void BeginLevel(UpdateContext updateContext, Level previousLevel, string targetSpawn); 15 | void BeforeUpdate(UpdateContext updateContext); 16 | void AfterUpdate(UpdateContext updateContext); 17 | void BeforeBackgroundDraw(DrawContext drawContext); 18 | void AfterDraw(DrawContext drawContext); 19 | 20 | void PlayerDidLeave(UpdateContext updateContext, int playerIndex); 21 | void PlayerDidJoin(UpdateContext updateContext, int playerIndex); 22 | 23 | void LevelWillChange(UpdateContext updateContext, LevelBehaviour nextLevelBehaviour, Level nextLevel); 24 | } 25 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/NetworkDataException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Runtime.Serialization; 6 | 7 | namespace Pixel3D.P2P 8 | { 9 | /// 10 | /// Represents an unrecoverable error that occurs when reading a NetIncomingMessage. 11 | /// Any method that dispatches NetIncomingMessages, whether it is directly from Lidgren 12 | /// or a message queued in a RemotePeer, should catch and handle this exception. 13 | /// 14 | [Serializable] 15 | public class NetworkDataException : Exception 16 | { 17 | public NetworkDataException() 18 | { 19 | } 20 | 21 | public NetworkDataException(string message) : base(message) 22 | { 23 | } 24 | 25 | public NetworkDataException(string message, Exception inner) : base(message, inner) 26 | { 27 | } 28 | 29 | protected NetworkDataException( 30 | SerializationInfo info, 31 | StreamingContext context) 32 | : base(info, context) 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/DepthSlice.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Animations 6 | { 7 | public class DepthSlice : IEquatable 8 | { 9 | public int xOffset; 10 | public int zOffset; 11 | public FrontBack[] depths; 12 | 13 | public int Width { get { return depths.Length; } } 14 | 15 | public static DepthSlice CreateBlank(int xOffset, int zOffset) 16 | { 17 | return new DepthSlice { xOffset = xOffset, zOffset = zOffset, depths = new FrontBack[1] }; 18 | } 19 | 20 | 21 | public bool Equals(DepthSlice other) 22 | { 23 | if(xOffset != other.xOffset || zOffset != other.zOffset || depths.Length != other.depths.Length) 24 | { 25 | return false; 26 | } 27 | 28 | // Too lazy to import memcmp... 29 | for(int i = 0; i < depths.Length; i++) 30 | if(depths[i].front != other.depths[i].front || depths[i].back != other.depths[i].back) 31 | return false; 32 | 33 | return true; 34 | } 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/SerializationRootAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization 6 | { 7 | /// 8 | /// Indicates to serialization generation that this is a root type to begin searching from. 9 | /// 10 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)] 11 | public sealed class SerializationRootAttribute : Attribute 12 | { 13 | } 14 | 15 | 16 | // TODO: Document attributes 17 | 18 | 19 | // TODO: Make this work for auto-properties? 20 | 21 | // TODO: This attribute is not yet used: 22 | ///// Apply to types that can be serialized as their System.Type 23 | //[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface 24 | // | AttributeTargets.Delegate | AttributeTargets.Enum, Inherited = false, AllowMultiple = false)] 25 | //public sealed class SerializedAsTypeAttribute : Attribute 26 | //{ 27 | //} 28 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization.Support/BuiltIn/SerializeIgnoreStateManagement.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System.IO; 5 | using Pixel3D.Serialization; 6 | using Pixel3D.Serialization.Context; 7 | using Pixel3D.StateManagement; 8 | 9 | namespace Pixel3D.BuiltIn 10 | { 11 | public static class SerializeIgnoreStateManagement 12 | { 13 | // Don't want to serialize into the "State" object (mostly during type discovery) 14 | // because it will always be a definition object that is manually created using 15 | // "AllStateInstances". Instead, just link up the reference by calling "Walk". 16 | 17 | [CustomFieldSerializer] 18 | public static void SerializeField(SerializeContext context, BinaryWriter bw, StateProvider.State value) 19 | { 20 | context.Walk(value); 21 | } 22 | 23 | [CustomFieldSerializer] 24 | public static void DeserializeField(DeserializeContext context, BinaryReader br, ref StateProvider.State value) 25 | { 26 | context.Walk(ref value); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Pixel3D.Pipeline/MaskDataReferenceResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Diagnostics; 5 | using System.IO; 6 | using Pixel3D.Animations; 7 | 8 | namespace Pixel3D.Pipeline 9 | { 10 | // TODO: Move out of Pipeline (this is used at runtime, not asset build time) 11 | // TODO: Once these are fixed, don't reference this assembly from engine 12 | 13 | public class MaskDataReferenceResolver : ICustomMaskDataReader 14 | { 15 | public MaskDataReferenceResolver(List packedDataArrays, BinaryReader br) 16 | { 17 | this.packedDataArrays = packedDataArrays; 18 | this.br = br; 19 | } 20 | 21 | BinaryReader br; 22 | List packedDataArrays; 23 | 24 | public uint[] Read(int length) 25 | { 26 | int index = br.ReadInt32(); 27 | Debug.Assert(packedDataArrays[index].Length == length); 28 | return packedDataArrays[index]; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/Pixel3D.Network.Test/ConsoleLogHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using Pixel3D.P2P.Diagnostics; 6 | 7 | namespace Pixel3D.Network.Test 8 | { 9 | internal class ConsoleLogHandler : NetworkLogHandler 10 | { 11 | public override void HandleLidgrenMessage(string message) 12 | { 13 | var fgc = Console.ForegroundColor; 14 | var bgc = Console.BackgroundColor; 15 | 16 | Console.ForegroundColor = ConsoleColor.Gray; 17 | Console.BackgroundColor = ConsoleColor.DarkBlue; 18 | Console.WriteLine(message); 19 | 20 | Console.ForegroundColor = fgc; 21 | Console.BackgroundColor = bgc; 22 | } 23 | 24 | public override void HandleMessage(string message) 25 | { 26 | var fgc = Console.ForegroundColor; 27 | var bgc = Console.BackgroundColor; 28 | 29 | Console.ForegroundColor = ConsoleColor.Gray; 30 | Console.BackgroundColor = ConsoleColor.DarkGreen; 31 | Console.WriteLine(message); 32 | 33 | Console.ForegroundColor = fgc; 34 | Console.BackgroundColor = bgc; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/Teleporter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.AssetManagement; 4 | 5 | namespace Pixel3D.Levels 6 | { 7 | public class Teleporter : Region, IEditorNameProvider 8 | { 9 | /// Set to true if you never want this teleporter to appear in random (or nearest/furthest) selections 10 | public bool neverSelectAtRandom; 11 | 12 | /// The asset path of the level to teleport to, or null for no teleport 13 | private string targetLevel; 14 | 15 | /// The target symbol the spawn points to use 16 | public string targetSpawn; 17 | 18 | // Provided to allow parameterless construction (due to presence of deserialization constructor) 19 | 20 | public string TargetLevel 21 | { 22 | get { return targetLevel; } 23 | set { targetLevel = value == null ? null : AssetManager.CanonicaliseAssetPath(value); } 24 | } 25 | 26 | 27 | public string EditorName 28 | { 29 | get { return string.Format("{0}_{1}", TargetLevel, targetSpawn); } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/DelegateHandling/DelegateTypeInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Reflection; 5 | 6 | namespace Pixel3D.Serialization.BuiltIn.DelegateHandling 7 | { 8 | internal class DelegateTypeInfo 9 | { 10 | private readonly Dictionary methodIdLookup; 11 | internal List methodInfoList; 12 | 13 | /// Must be in network-safe order! 14 | internal DelegateTypeInfo(List methodInfoList) 15 | { 16 | this.methodInfoList = methodInfoList; 17 | methodIdLookup = new Dictionary(); 18 | 19 | for (var i = 0; i < methodInfoList.Count; i++) methodIdLookup.Add(methodInfoList[i].method, i); 20 | } 21 | 22 | internal int GetIdForMethod(MethodInfo methodInfo) 23 | { 24 | return methodIdLookup[methodInfo]; 25 | } 26 | 27 | internal DelegateMethodInfo GetMethodInfoForId(int methodId) 28 | { 29 | return methodInfoList[methodId]; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/DelegateHandling/InvocationListEnumerator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Serialization.BuiltIn.DelegateHandling 6 | { 7 | public struct InvocationListEnumerator 8 | { 9 | internal InvocationListEnumerator(object[] invocationList, int invocationCount, Delegate theDelegate) : this() 10 | { 11 | this.invocationList = invocationList; 12 | this.invocationCount = invocationCount; 13 | Current = theDelegate; 14 | index = 0; 15 | } 16 | 17 | private readonly object[] invocationList; 18 | private readonly int invocationCount; 19 | private int index; 20 | 21 | public Delegate Current { get; private set; } 22 | 23 | public bool MoveNext() 24 | { 25 | if (invocationList == null) 26 | { 27 | if (index == 0) 28 | { 29 | index++; 30 | return true; 31 | } 32 | } 33 | else if (index < invocationCount) 34 | { 35 | Current = (Delegate) invocationList[index]; 36 | index++; 37 | return true; 38 | } 39 | 40 | return false; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/MissingAssetFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace Pixel3D.AssetManagement 7 | { 8 | public class MissingAssetFactory 9 | { 10 | public delegate object CreateMissingAsset(IServiceProvider services, string fullPath); 11 | 12 | private static readonly Dictionary CreateRegistry = 13 | new Dictionary(); 14 | 15 | public static void Clear() 16 | { 17 | CreateRegistry.Clear(); 18 | } 19 | 20 | public static void Add(CreateMissingAsset createMissingAsset) 21 | { 22 | CreateRegistry.Add(typeof(T), createMissingAsset); 23 | } 24 | 25 | public static T Create(IServiceProvider services, string fullPath) where T : class 26 | { 27 | CreateMissingAsset createMissingAsset; 28 | if (CreateRegistry.TryGetValue(typeof(T), out createMissingAsset)) 29 | return createMissingAsset(services, fullPath) as T; 30 | throw new InvalidOperationException("Unknown or unsupported asset type"); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Pixel3D.Levels/Region.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.ActorManagement; 4 | using Pixel3D.Physics; 5 | 6 | namespace Pixel3D.Levels 7 | { 8 | public class Region 9 | { 10 | public int endY = WorldPhysics.MaximumHeight; 11 | 12 | /// The region in the XZ (floor) plane where the mask is active 13 | public MaskData mask; 14 | 15 | /// Index into navigation info for the given region (expect serialization to set these correctly) 16 | public int regionIndex; 17 | 18 | public int startY; 19 | 20 | // Provided to allow parameterless construction (due to presence of deserialization constructor) 21 | 22 | public bool Contains(Actor subject) 23 | { 24 | return Contains(subject.position); 25 | } 26 | 27 | public bool Contains(Position position) 28 | { 29 | return position.Y >= startY && position.Y < endY && mask.GetOrDefault(position.X, position.Z); 30 | } 31 | 32 | public bool ContainsXZ(int x, int z) 33 | { 34 | if (mask.GetOrDefault(x, z)) return true; 35 | return false; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Pixel3D 2 | ======= 3 | 4 | A 2.5D pixel game engine built on FNA. 5 | 6 | It was used to create the game [River City Ransom: Underground](https://store.steampowered.com/app/422810/River_City_Ransom_Underground/). 7 | 8 | NOTE: You will need to source your own copy of fxc.exe and place it in /builds/tools 9 | 10 | Pixel3D is built on top of FNA, all relevant licenses and attribution is available here: 11 | https://github.com/FNA-XNA/FNA/tree/master/licenses 12 | 13 | Installation 14 | ============ 15 | 16 | Requires the following system installs: 17 | - DirectX SDK (June 2010) on Windows 18 | - Wine with `winetricks d3dcompiler_43` on OSX 19 | - MonoGame 3.6 (or newer?) on both Windows and OSX 20 | 21 | Requires the following directories to be added at the same level as the Solution 22 | - "FNA" containing FNA project from https://github.com/FNA-XNA/FNA 23 | - "fnalibs" (_case sensitive_) containing FNA libraries from http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 24 | 25 | fxc.exe should live in `build\tools` 26 | 27 | Note that shaders need to be loaded from fxb files, not through ContentManager (example is provided) 28 | 29 | Should work on both VS2010 (and probably newer) and VS Mac / VS 2017 30 | -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/MinMax.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Navigation 6 | { 7 | public struct MinMax 8 | { 9 | public int min, max; 10 | 11 | public MinMax(int min, int max) 12 | { 13 | this.min = min; 14 | this.max = max; 15 | } 16 | 17 | 18 | public static bool Clip(ref MinMax current, MinMax next) 19 | { 20 | // NOTE: This solves most but not all slop issues (needs more testing) 21 | // NOTE: Arbitrary value - should perhaps depend on movement speed (but this is ok for both walking and running) 22 | const int cornerSlop = 3; 23 | 24 | if (next.max <= current.min) 25 | { 26 | current.max = Math.Min(current.min + cornerSlop, current.max); 27 | return false; 28 | } 29 | 30 | if (next.min >= current.max) 31 | { 32 | current.min = Math.Max(current.max - cornerSlop, current.min); 33 | return false; 34 | } 35 | 36 | if (next.max < current.max) 37 | current.max = next.max; 38 | if (next.min > current.min) 39 | current.min = next.min; 40 | 41 | return true; 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/Pixel3D.Network/NetworkInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using Microsoft.Xna.Framework.Input; 6 | 7 | namespace Pixel3D.Network // Put it in with the InputState struct 8 | { 9 | public static class NetworkInput 10 | { 11 | public static InputState MapInputs(this KeyboardState keyboardState, Keys[] keyboardMap) 12 | { 13 | if (keyboardMap.Length > 32) 14 | throw new ArgumentException("Too many inputs specified"); 15 | 16 | InputState output = 0; 17 | for (var i = 0; i < keyboardMap.Length; i++) 18 | if (keyboardState.IsKeyDown(keyboardMap[i])) 19 | output |= (InputState) (1u << i); 20 | 21 | return output; 22 | } 23 | 24 | public static InputState MapInputs(this GamePadState gamePadState, Buttons[] gamePadMap) 25 | { 26 | if (gamePadMap.Length > 32) 27 | throw new ArgumentException("Too many inputs specified"); 28 | 29 | InputState output = 0; 30 | for (var i = 0; i < gamePadMap.Length; i++) 31 | if (gamePadState.IsButtonDown(gamePadMap[i])) 32 | output |= (InputState) (1u << i); 33 | 34 | return output; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /test/Pixel3D.Serialization.Demo/TestTypes/ContainerTypes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Pixel3D.Serialization.Demo.TestTypes 5 | { 6 | struct SimpleStruct 7 | { 8 | int member; 9 | 10 | public SimpleStruct(int value) { this.member = value; } 11 | } 12 | 13 | class SimpleClass 14 | { 15 | int member; 16 | 17 | public SimpleClass(int value) { this.member = value; } 18 | 19 | public override bool Equals(object obj) 20 | { 21 | if(obj.GetType() == typeof(SimpleClass)) 22 | { 23 | return (member == ((SimpleClass)obj).member); 24 | } 25 | 26 | return false; 27 | } 28 | 29 | public override int GetHashCode() 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | } 34 | 35 | 36 | [SerializationRoot] 37 | class ContainerTypes 38 | { 39 | List list1 = new List(); 40 | List> nestedList = new List>(); 41 | 42 | SimpleStruct[] array1 = new SimpleStruct[3]; 43 | SimpleClass[] array2 = new SimpleClass[3]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/CRTSim/GraphicsDeviceExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Xna.Framework; 2 | using Microsoft.Xna.Framework.Graphics; 3 | 4 | namespace CRTSim 5 | { 6 | public static class GraphicsDeviceExtensions 7 | { 8 | public static void LazySetupRenderTarget(this GraphicsDevice device, ref RenderTarget2D renderTarget, Point renderSize, Color? clearColor = null) 9 | { 10 | device.LazySetupRenderTarget(ref renderTarget, renderSize.X, renderSize.Y, clearColor); 11 | } 12 | 13 | public static void LazySetupRenderTarget(this GraphicsDevice device, ref RenderTarget2D renderTarget, int width, int height, Color? clearColor = null) 14 | { 15 | int maxTextureSize = device.GraphicsProfile == GraphicsProfile.Reach ? 2048 : 4096; 16 | width = width.Clamp(1, maxTextureSize); 17 | height = height.Clamp(1, maxTextureSize); 18 | 19 | if (renderTarget == null || renderTarget.Width != width || renderTarget.Height != height) 20 | { 21 | if (renderTarget != null) 22 | renderTarget.Dispose(); 23 | renderTarget = new RenderTarget2D(device, width, height); 24 | 25 | if (clearColor.HasValue) 26 | { 27 | device.SetRenderTarget(renderTarget); 28 | device.Clear(clearColor.GetValueOrDefault()); 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Pixel3D.Pipeline/Pixel3D.Pipeline.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | Pixel3D.Pipeline.FNA 7 | Pixel3D.Pipeline 8 | Debug;Release;Retail 9 | 10 | 11 | 12 | TRACE;DEBUG;DEVELOPER 13 | 14 | 15 | 16 | TRACE;DEVELOPER 17 | 18 | 19 | 20 | true 21 | TRACE 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Pixel3D.P2P/P2PServerMessageExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Lidgren.Network; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | internal static class P2PServerMessageExtensions 9 | { 10 | public static P2PServerMessage Validate(this P2PServerMessage m) 11 | { 12 | if (m < 0 || m > P2PServerMessage.Unknown) 13 | return P2PServerMessage.Unknown; 14 | return m; 15 | } 16 | 17 | public static void Write(this NetOutgoingMessage message, P2PServerMessage m) 18 | { 19 | message.Write((byte) m); 20 | } 21 | 22 | public static P2PServerMessage TryReadP2PServerMessage(this NetIncomingMessage message) 23 | { 24 | try 25 | { 26 | return ((P2PServerMessage) message.ReadByte()).Validate(); 27 | } 28 | catch 29 | { 30 | return P2PServerMessage.Unknown; 31 | } 32 | } 33 | 34 | public static P2PServerMessage TryPeekP2PServerMessage(this NetIncomingMessage message) 35 | { 36 | try 37 | { 38 | return ((P2PServerMessage) message.PeekByte()).Validate(); 39 | } 40 | catch 41 | { 42 | return P2PServerMessage.Unknown; 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Discovery/ReadIL/OpCodeValues.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Serialization.Discovery.ReadIL 4 | { 5 | internal static class OpCodeValues 6 | { 7 | // Incomplete list at the moment (just using these for optimising "hot" paths) 8 | // (because CLR equality check for OpCode is very much sub-optimal) 9 | 10 | public const ushort Ldarg_0 = 0x02; 11 | public const ushort Ldarg_1 = 0x03; 12 | public const ushort Ldarg_2 = 0x04; 13 | public const ushort Ldarg_3 = 0x05; 14 | public const ushort Ldarg_S = 0x0e; 15 | public const ushort Ldarg = 0xfe09; 16 | 17 | public const ushort Ldloc_0 = 0x06; 18 | public const ushort Ldloc_1 = 0x07; 19 | public const ushort Ldloc_2 = 0x08; 20 | public const ushort Ldloc_3 = 0x09; 21 | public const ushort Ldloc_S = 0x11; 22 | public const ushort Ldloc = 0xfe0c; 23 | 24 | public const ushort Dup = 0x25; 25 | public const ushort Ldnull = 0x14; 26 | public const ushort Newobj = 0x73; 27 | public const ushort Ldfld = 0x7b; 28 | public const ushort Ldftn = 0xfe06; 29 | public const ushort Ldvirtftn = 0xfe07; 30 | } 31 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/ILWriting/ILGenContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Serialization.MethodProviders; 4 | 5 | namespace Pixel3D.Serialization.Generator.ILWriting 6 | { 7 | // This class exists to allow for the generator code to be bi-directional (cutting down on code duplication in the generator) 8 | internal class ILGenContext 9 | { 10 | public readonly Direction direction; 11 | public readonly MethodProvider fieldSerializationMethods; 12 | public readonly MethodProvider referenceTypeSerializationMethods; 13 | 14 | public ILGenContext(Direction direction, MethodProvider fieldSerializeMethods, 15 | MethodProvider referenceTypeSerializeMethods) 16 | { 17 | this.direction = direction; 18 | fieldSerializationMethods = fieldSerializeMethods; 19 | referenceTypeSerializationMethods = referenceTypeSerializeMethods; 20 | } 21 | 22 | public bool Serialize 23 | { 24 | get { return direction == Direction.Serialize; } 25 | } 26 | 27 | public bool Deserialize 28 | { 29 | get { return direction != Direction.Serialize; } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/ProtocolException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Diagnostics; 6 | using System.Runtime.Serialization; 7 | 8 | namespace Pixel3D.P2P 9 | { 10 | /// 11 | /// Represents a protocol error (ie: badly formed packet). 12 | /// In debug mode, with trusted peers, should never happen unless there's a programming error - so break into the 13 | /// debugger. 14 | /// But could theoretically be caused by a remote client with a modified game. 15 | /// 16 | [Serializable] 17 | public class ProtocolException : NetworkDataException 18 | { 19 | public ProtocolException() 20 | { 21 | Debug.Assert(false); 22 | } 23 | 24 | public ProtocolException(string message) : base(message) 25 | { 26 | Debug.Assert(false); 27 | } 28 | 29 | public ProtocolException(string message, Exception inner) : base(message, inner) 30 | { 31 | Debug.Assert(false); 32 | } 33 | 34 | protected ProtocolException( 35 | SerializationInfo info, 36 | StreamingContext context) 37 | : base(info, context) 38 | { 39 | Debug.Assert(false); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Pixel3D/HeightmapInstructionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using Pixel3D.Animations; 5 | 6 | namespace Pixel3D 7 | { 8 | public static class HeightmapInstructionExtensions 9 | { 10 | #region Serialization 11 | 12 | public static void Serialize(this List instructions, AnimationSerializeContext context) 13 | { 14 | context.bw.Write(instructions != null); 15 | if (instructions != null) 16 | { 17 | context.bw.Write(instructions.Count); 18 | for (var i = 0; i < instructions.Count; i++) 19 | instructions[i].Serialize(context); 20 | } 21 | } 22 | 23 | public static List DeserializeHeightmapInstructions(this AnimationDeserializeContext context) 24 | { 25 | if (context.br.ReadBoolean()) 26 | { 27 | int count = context.br.ReadInt32(); 28 | var instructions = new List(count); 29 | for (var i = 0; i < count; i++) 30 | instructions.Add(new HeightmapInstruction(context)); 31 | return instructions; 32 | } 33 | return null; 34 | } 35 | 36 | #endregion 37 | } 38 | } -------------------------------------------------------------------------------- /src/Lidgren.Network/Documentation/Improvements.txt: -------------------------------------------------------------------------------- 1 | 2 | Improvements over last version of library: 3 | 4 | * New delivery type: Reliable sequenced (Lost packets are resent but late arrivals are dropped) 5 | * Disconnects and shutdown requests are now queued properly, so calling shutdown will still send any queued messages before shutting down 6 | * All messages are pooled/recycled for zero garbage 7 | * Reduced CPU usage and lower latencies (in the <1 ms range, but still) due to better socket polling 8 | * All public members of NetPeer/NetConnection are completely thread safe 9 | * Larger number of delivery channels 10 | * More exact roundtrip measurement 11 | * Method serialize entire objects via reflection 12 | * Unique identifier now exists for all peers/connections 13 | * More flexible peer discovery; filters possible and arbitrary data can be sent with response 14 | * Much better protection against malformed messages crashing the app 15 | 16 | API enhancements: 17 | * NetPeerConfiguration immutable properties now locked once NetPeer is initialized 18 | * Messages cannot be send twice by accident 19 | * Impossible to confuse sending and receiving buffers since they're different classes 20 | * No more confusion if user should create a buffer or preallocate and reuse 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Pixel3D.Levels/LevelSubBehaviour.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.ActorManagement; 4 | using Pixel3D.Animations; 5 | 6 | namespace Pixel3D.Levels 7 | { 8 | public abstract class LevelSubBehaviour : ILevelSubBehaviour 9 | { 10 | public virtual void BeforeBeginLevel(UpdateContext updateContext) { } 11 | 12 | public virtual void BeginLevelStoryTriggers(UpdateContext updateContext) { } 13 | 14 | public virtual void BeginLevel(UpdateContext updateContext, Level previousLevel, string targetSpawn) { } 15 | 16 | public virtual void BeforeUpdate(UpdateContext updateContext) { } 17 | 18 | public virtual void AfterUpdate(UpdateContext updateContext) { } 19 | 20 | public virtual void BeforeBackgroundDraw(DrawContext drawContext) { } 21 | 22 | public virtual void AfterDraw(DrawContext drawContext) { } 23 | 24 | public virtual void PlayerDidLeave(UpdateContext updateContext, int playerIndex) { } 25 | 26 | public virtual void PlayerDidJoin(UpdateContext updateContext, int playerIndex) { } 27 | 28 | public virtual void LevelWillChange(UpdateContext updateContext, LevelBehaviour nextLevelBehaviour, Level nextLevel) { } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/AudioDevice.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Diagnostics; 6 | using Microsoft.Xna.Framework.Audio; 7 | 8 | namespace Pixel3D.Audio 9 | { 10 | public static class AudioDevice 11 | { 12 | private static bool? _available; 13 | 14 | public static bool Available 15 | { 16 | get 17 | { 18 | if (_available.HasValue) 19 | return _available.Value; 20 | _available = AudioDeviceCheck(); 21 | return _available.GetValueOrDefault(); 22 | } 23 | } 24 | 25 | private static bool AudioDeviceCheck() 26 | { 27 | try 28 | { 29 | SoundEffect.MasterVolume = 1f; 30 | // The above line should throw an exception if there is no audio device 31 | return true; 32 | } 33 | catch (NoAudioHardwareException) 34 | { 35 | Debug.WriteLine("No audio hardware available"); 36 | return false; 37 | } 38 | catch (Exception e) 39 | { 40 | Debug.WriteLine("Exception during audio device testing. XNA or something under it doing something dumb."); 41 | Log.Current.WarnException("Exception during audio device testing", e); 42 | return false; 43 | } 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Pixel3D.Network.Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp2.2 6 | AnyCPU;x64 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Windows 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/AttachmentTracking.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Pixel3D.Animations; 4 | 5 | namespace Pixel3D.ActorManagement 6 | { 7 | public class OutgoingAttachmentAttempt 8 | { 9 | public readonly Animation animation; 10 | public readonly OutgoingAttachmentView outgoingAttachmentView; 11 | 12 | public OutgoingAttachmentAttempt(Animation animation, OutgoingAttachmentView outgoingAttachmentView) 13 | { 14 | this.animation = animation; 15 | this.outgoingAttachmentView = outgoingAttachmentView; 16 | } 17 | } 18 | 19 | 20 | public class IncomingAttachmentAttempt 21 | { 22 | public readonly Animation animation; 23 | public readonly Position incomingAttachment; 24 | public readonly bool inRange; 25 | public readonly OutgoingAttachmentView outgoingAttachmentView; 26 | 27 | public IncomingAttachmentAttempt(OutgoingAttachmentView outgoingAttachmentView, Animation animation, 28 | Position incomingAttachment, bool inRange) 29 | { 30 | this.outgoingAttachmentView = outgoingAttachmentView; 31 | this.animation = animation; 32 | this.incomingAttachment = incomingAttachment; 33 | this.inRange = inRange; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/TagSetExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.ActorManagement 4 | { 5 | public static class TagSetExtensions 6 | { 7 | public static TagSet Flip(this TagSet @this) 8 | { 9 | var count = @this.Count; 10 | for (var i = 0; i < count; i++) 11 | { 12 | var tag = @this[i]; 13 | if (tag == Symbols.Left || tag == Symbols.Right || tag == Symbols.Front || tag == Symbols.Back) 14 | return FlipHelper(@this, i); 15 | } 16 | 17 | return @this; 18 | } 19 | 20 | private static TagSet FlipHelper(TagSet @this, int index) 21 | { 22 | var tags = @this.ToArray(); 23 | for (var i = index; i < tags.Length; i++) 24 | if (tags[i] == Symbols.Left) 25 | tags[i] = Symbols.Right; 26 | else if (tags[i] == Symbols.Right) 27 | tags[i] = Symbols.Left; 28 | else if (tags[i] == Symbols.Back) 29 | tags[i] = Symbols.Front; 30 | else if (tags[i] == Symbols.Front) 31 | tags[i] = Symbols.Back; 32 | return new TagSet(tags); 33 | } 34 | 35 | public static TagSet MaybeFlip(this TagSet @this, bool shouldFlip) 36 | { 37 | return shouldFlip ? Flip(@this) : @this; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Pixel3D.Common/BinaryReaderWriterExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | 5 | namespace Pixel3D // <- Put in the same namespace as BinaryReader, etc 6 | { 7 | public static class BinaryReaderWriterExtensions 8 | { 9 | public static void WriteSmallUInt32(this BinaryWriter bw, uint value) 10 | { 11 | while (value >= 0x80u) 12 | { 13 | bw.Write((byte) (value | 0x80u)); // <- Write lower 7 bits and more data flag 14 | value >>= 7; 15 | } 16 | 17 | bw.Write((byte) value); // <- Write remaining bits 18 | } 19 | 20 | public static uint ReadSmallUInt32(this BinaryReader br) 21 | { 22 | var offset = 0; 23 | uint result = 0; 24 | byte v; 25 | while (((v = br.ReadByte()) & 0x80u) != 0) 26 | { 27 | result |= (v & 0x7Fu) << offset; 28 | offset += 7; 29 | } 30 | 31 | result |= (uint) v << offset; 32 | return result; 33 | } 34 | 35 | public static void WriteSmallInt32(this BinaryWriter bw, int value) 36 | { 37 | WriteSmallUInt32(bw, (uint) value); 38 | } 39 | 40 | public static int ReadSmallInt32(this BinaryReader br) 41 | { 42 | return (int) ReadSmallUInt32(br); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/GameState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | 5 | namespace Pixel3D.ActorManagement 6 | { 7 | public abstract class GameState : IGameState 8 | { 9 | /// List of actors that currently exist in the world 10 | public readonly List actors = new List(); 11 | 12 | public readonly ushort[] cueStates; 13 | public readonly Definitions definitions; 14 | 15 | // can be used for duty cycling (i.e recover 2 hp every 15 ticks) (not suitable for timers) 16 | public int frameCounter; 17 | 18 | // Host derived content 19 | public byte language = 0; 20 | 21 | public GameState(Definitions definitions) 22 | { 23 | this.definitions = definitions; 24 | cueStates = new ushort[definitions.cuesWithIds]; 25 | } 26 | 27 | public virtual Definitions Definitions 28 | { 29 | get { return definitions; } 30 | } 31 | 32 | public abstract int MaxPlayers { get; } 33 | public abstract Position? GetPlayerPosition(int playerIndex); 34 | 35 | public virtual void Update(UpdateContext updateContext, MultiInputState currentRawInput) 36 | { 37 | frameCounter++; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/ShutdownWaiter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System.Diagnostics; 5 | using System.Threading; 6 | using Lidgren.Network; 7 | 8 | namespace Pixel3D.P2P 9 | { 10 | /// 11 | /// This is a dirty hack, because Lidgren marks its network threads as background. 12 | /// So suddenly exiting the main thread does not give the network threads a chance to 13 | /// exit cleanly (which includes sending disconnection notification to the remote, 14 | /// which will cause that end to time-out instead). So give them a chance to exit. 15 | /// 16 | public struct ShutdownWaiter 17 | { 18 | internal NetPeer netPeer; 19 | 20 | internal ShutdownWaiter(NetPeer netPeer) 21 | { 22 | this.netPeer = netPeer; 23 | } 24 | 25 | public void Wait(int milliseconds) 26 | { 27 | const int tickRate = 20; // ms 28 | for (var i = 0; i < milliseconds; i += tickRate) 29 | { 30 | if (netPeer.Status == NetPeerStatus.NotRunning) 31 | return; // Done 32 | Thread.Sleep(tickRate); 33 | } 34 | 35 | // If we get here, it didn't shutdown cleanly. Exit anyway. 36 | Debug.WriteLine("Did not shutdown cleanly!"); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/CRTSim/Palette.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using Microsoft.Xna.Framework; 8 | using Microsoft.Xna.Framework.Graphics; 9 | 10 | namespace CRTSim 11 | { 12 | public class Palette 13 | { 14 | public Color white, black; 15 | public Texture3D palette; 16 | 17 | public static Palette Load(GraphicsDevice device, string path) 18 | { 19 | Palette result = new Palette(); 20 | 21 | byte[] data = File.ReadAllBytes(path); 22 | 23 | // Figure out the size from the data length. Gracefully handle wrong-sized data (in case modders mess with it). 24 | int size = 1; 25 | while(size * size * size * 4 <= data.Length) 26 | size++; 27 | size--; 28 | Debug.Assert(size * size * size * 4 == data.Length); // <- Warn if the data is the wrong length 29 | 30 | result.white.PackedValue = BitConverter.ToUInt32(data, 0); 31 | result.white.PackedValue = BitConverter.ToUInt32(data, (size*size*size-1) * 4); 32 | 33 | result.palette = new Texture3D(device, size, size, size, false, SurfaceFormat.Color); 34 | result.palette.SetData(data, 0, size * size * size * 4); 35 | return result; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Lidgren.Network/NetDeliveryMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Lidgren.Network 6 | { 7 | /// 8 | /// How the library deals with resends and handling of late messages 9 | /// 10 | public enum NetDeliveryMethod : byte 11 | { 12 | // 13 | // Actually a publicly visible subset of NetMessageType 14 | // 15 | 16 | /// 17 | /// Indicates an error 18 | /// 19 | Unknown = 0, 20 | 21 | /// 22 | /// Unreliable, unordered delivery 23 | /// 24 | Unreliable = 1, 25 | 26 | /// 27 | /// Unreliable delivery, but automatically dropping late messages 28 | /// 29 | UnreliableSequenced = 2, 30 | 31 | /// 32 | /// Reliable delivery, but unordered 33 | /// 34 | ReliableUnordered = 34, 35 | 36 | /// 37 | /// Reliable delivery, except for late messages which are dropped 38 | /// 39 | ReliableSequenced = 35, 40 | 41 | /// 42 | /// Reliable, ordered delivery 43 | /// 44 | ReliableOrdered = 67, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Pixel3D.Audio/PlayCueParameters.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Diagnostics; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | /// 8 | /// Holds the gameplay-affecting logic for playing a cue 9 | /// 10 | public struct PlayCueParameters 11 | { 12 | public int soundIndex; 13 | public float cuePitch; 14 | 15 | public const int NO_SOUND = -1; 16 | public const int MISSING_CUE = -2; 17 | 18 | 19 | /// Potentially gameplay-mutating logic for cue playback (modifies `random` and `cueStates`) 20 | public static PlayCueParameters GetParameters(Cue cue, XorShift random, ushort[] cueStates) 21 | { 22 | if (cue == null) 23 | return new PlayCueParameters {soundIndex = NO_SOUND}; 24 | if (ReferenceEquals(cue, Cue.missingCue)) 25 | return new PlayCueParameters {soundIndex = MISSING_CUE}; 26 | if (cue.SoundCount == 0) 27 | return new PlayCueParameters {soundIndex = NO_SOUND}; 28 | 29 | PlayCueParameters result; 30 | result.cuePitch = cue.SelectPitch(random); 31 | result.soundIndex = cue.SelectSound(random, cueStates); 32 | 33 | Debug.Assert(result.soundIndex >= 0); 34 | 35 | return result; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/MethodBuilderCreatorCreator.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.Reflection.Emit; 5 | 6 | namespace Pixel3D.Serialization.Generator 7 | { 8 | internal class MethodBuilderCreatorCreator : MethodCreatorCreator 9 | { 10 | private readonly ModuleBuilder moduleBuilder; 11 | private readonly string @namespace; 12 | 13 | 14 | private readonly List typeBuilders = new List(); 15 | 16 | public MethodBuilderCreatorCreator(ModuleBuilder moduleBuilder, string @namespace) 17 | { 18 | this.moduleBuilder = moduleBuilder; 19 | this.@namespace = @namespace; 20 | } 21 | 22 | public void Finish() 23 | { 24 | foreach (var typeBuilder in typeBuilders) 25 | { 26 | #if NET40 27 | typeBuilder.CreateType(); 28 | #else 29 | typeBuilder.CreateTypeInfo(); 30 | #endif 31 | } 32 | } 33 | 34 | 35 | public override MethodCreator Create(string containingTypeName) 36 | { 37 | var typeBuilder = moduleBuilder.DefineType(@namespace + "." + containingTypeName); 38 | typeBuilders.Add(typeBuilder); 39 | return new MethodBuilderCreator(typeBuilder); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/OutgoingAttachmentView.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | namespace Pixel3D.Animations 4 | { 5 | public struct OutgoingAttachmentView 6 | { 7 | public OutgoingAttachmentView(OutgoingAttachment sourceAttachment, Position sourcePosition, bool sourceFlipX) 8 | { 9 | attachment = sourceAttachment; 10 | facingLeft = sourceFlipX; 11 | position = sourcePosition; 12 | 13 | if(sourceAttachment != null) 14 | { 15 | position += sourceAttachment.position.MaybeFlipX(sourceFlipX); 16 | 17 | attachRange = sourceAttachment.attachRange; 18 | if(sourceFlipX) 19 | attachRange.FlipXInPlace(); 20 | } 21 | else 22 | { 23 | attachRange = default(AABB); 24 | } 25 | 26 | attachRange += position; 27 | } 28 | 29 | public bool IsValid { get { return attachment != null; } } 30 | 31 | public OutgoingAttachment attachment; 32 | public bool facingLeft; 33 | 34 | public Position position; 35 | public AABB attachRange; 36 | 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Generator/GeneratorResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Reflection; 6 | using Pixel3D.Serialization.BuiltIn.DelegateHandling; 7 | 8 | namespace Pixel3D.Serialization.Generator 9 | { 10 | public class GeneratorResult 11 | { 12 | internal readonly DeserializeDispatchDelegate deserializeDispatch; 13 | 14 | internal readonly SerializationMethodProviders serializationMethods; 15 | 16 | internal readonly Dictionary serializeDispatchTable; 17 | 18 | internal Dictionary delegateTypeTable; 19 | 20 | // Valid modules for serializing System.Type 21 | internal List moduleTable; 22 | 23 | internal GeneratorResult(SerializationMethodProviders serializationMethods, 24 | Dictionary dispatchTable, 25 | DeserializeDispatchDelegate deserializeDispatch, 26 | List moduleTable) 27 | { 28 | this.serializationMethods = serializationMethods; 29 | serializeDispatchTable = dispatchTable; 30 | this.deserializeDispatch = deserializeDispatch; 31 | this.moduleTable = moduleTable; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/P2PServerMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.P2P 5 | { 6 | /// Messages from the P2P server to the P2P client 7 | internal enum P2PServerMessage 8 | { 9 | /// 10 | /// Initial data for to connect to the P2P network 11 | /// 12 | NetworkStartInfo, 13 | 14 | /// 15 | /// Another client has joined the network. Perform NAT punchthrough to that peer and allow them to connect. 16 | /// 17 | PeerJoinedNetwork, 18 | 19 | /// 20 | /// Another client has left the network. Disconnect them. 21 | /// 22 | PeerLeftNetwork, 23 | 24 | /// 25 | /// Another client on the network reported you disconnected. Are you still alive? 26 | /// 27 | YouWereDisconnectedBy, 28 | 29 | /// 30 | /// A peer just became connected to the network, connect them at the application layer. 31 | /// 32 | PeerBecameApplicationConnected, 33 | 34 | /// 35 | /// We just became the server due to host migration 36 | /// 37 | HostMigration, 38 | 39 | 40 | Unknown 41 | } 42 | } -------------------------------------------------------------------------------- /src/Pixel3D.Common/MultiInputState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Diagnostics; 5 | 6 | namespace Pixel3D 7 | { 8 | [Serializable] 9 | public struct MultiInputState 10 | { 11 | public InputState Player1; 12 | public InputState Player2; 13 | public InputState Player3; 14 | public InputState Player4; 15 | 16 | public const int Count = 4; 17 | 18 | public InputState this[int playerNumber] 19 | { 20 | get 21 | { 22 | switch (playerNumber) 23 | { 24 | case 0: return Player1; 25 | case 1: return Player2; 26 | case 2: return Player3; 27 | case 3: return Player4; 28 | default: 29 | Debug.Assert(false); // Not a valid player number 30 | return default(InputState); 31 | } 32 | } 33 | set 34 | { 35 | switch (playerNumber) 36 | { 37 | case 0: 38 | Player1 = value; 39 | break; 40 | case 1: 41 | Player2 = value; 42 | break; 43 | case 2: 44 | Player3 = value; 45 | break; 46 | case 3: 47 | Player4 = value; 48 | break; 49 | default: 50 | Debug.Assert(false); // Not a valid player number 51 | break; 52 | } 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/SerializeStack.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using Pixel3D.Serialization.Context; 6 | 7 | namespace Pixel3D.Serialization.BuiltIn 8 | { 9 | internal static class SerializeStack 10 | { 11 | [CustomSerializer] 12 | public static void Serialize(SerializeContext context, BinaryWriter bw, Stack stack) 13 | { 14 | context.VisitObject(stack); 15 | 16 | bw.WriteSmallInt32(stack.Count); 17 | foreach (var entry in stack) 18 | { 19 | var item = entry; 20 | Field.Serialize(context, bw, ref item); 21 | } 22 | 23 | context.LeaveObject(); 24 | } 25 | 26 | [CustomSerializer] 27 | public static void Deserialize(DeserializeContext context, BinaryReader br, Stack stack) 28 | { 29 | context.VisitObject(stack); 30 | 31 | var count = br.ReadSmallInt32(); 32 | 33 | stack.Clear(); 34 | 35 | for (var i = 0; i < count; i++) 36 | { 37 | var item = default(T); 38 | Field.Deserialize(context, br, ref item); 39 | stack.Push(item); 40 | } 41 | } 42 | 43 | [CustomInitializer] 44 | public static Stack Initialize() 45 | { 46 | return new Stack(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/SerializeQueue.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using Pixel3D.Serialization.Context; 6 | 7 | namespace Pixel3D.Serialization.BuiltIn 8 | { 9 | internal static class SerializeQueue 10 | { 11 | [CustomSerializer] 12 | public static void Serialize(SerializeContext context, BinaryWriter bw, Queue queue) 13 | { 14 | context.VisitObject(queue); 15 | 16 | bw.WriteSmallInt32(queue.Count); 17 | foreach (var entry in queue) 18 | { 19 | var item = entry; 20 | Field.Serialize(context, bw, ref item); 21 | } 22 | 23 | context.LeaveObject(); 24 | } 25 | 26 | [CustomSerializer] 27 | public static void Deserialize(DeserializeContext context, BinaryReader br, Queue queue) 28 | { 29 | context.VisitObject(queue); 30 | 31 | var count = br.ReadSmallInt32(); 32 | 33 | queue.Clear(); 34 | 35 | for (var i = 0; i < count; i++) 36 | { 37 | var item = default(T); 38 | Field.Deserialize(context, br, ref item); 39 | queue.Enqueue(item); 40 | } 41 | } 42 | 43 | [CustomInitializer] 44 | public static Queue Initialize() 45 | { 46 | return new Queue(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization.Support/BuiltIn/SerializeIgnoreAudio.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using System; 5 | using System.IO; 6 | using Microsoft.Xna.Framework.Audio; 7 | using Pixel3D.Audio; 8 | using Pixel3D.Serialization; 9 | using Pixel3D.Serialization.Context; 10 | 11 | namespace Pixel3D.BuiltIn 12 | { 13 | public static class SerializeIgnoreAudio 14 | { 15 | // "Ignore" serializer, as per SerializeIgnoreXNA -- we want to be able to store a ref for the definition table, but we can't deserialize a sound effect 16 | [CustomSerializer] public static void Serialize(SerializeContext context, BinaryWriter bw, SafeSoundEffect value) { context.VisitObject(value); context.LeaveObject(); } 17 | [CustomSerializer] public static void Deserialize(DeserializeContext context, BinaryReader br, SafeSoundEffect value) { throw new InvalidOperationException(); } 18 | 19 | // Outright block SoundEffect from serializing 20 | [CustomSerializer] public static void Serialize(SerializeContext context, BinaryWriter bw, SoundEffect value) { throw new InvalidOperationException(); } 21 | [CustomSerializer] public static void Deserialize(DeserializeContext context, BinaryReader br, SoundEffect value) { throw new InvalidOperationException(); } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/BuiltIn/SerializeStringBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using System.Text; 5 | using Pixel3D.Serialization.Context; 6 | 7 | namespace Pixel3D.Serialization.BuiltIn 8 | { 9 | internal class SerializeStringBuilder 10 | { 11 | [CustomFieldSerializer] 12 | public static void SerializeField(SerializeContext context, BinaryWriter bw, StringBuilder stringBuilder) 13 | { 14 | if (!context.Walk(stringBuilder)) // null check 15 | return; 16 | 17 | context.VisitObject(stringBuilder); 18 | 19 | bw.WriteSmallInt32(stringBuilder.Length); 20 | for (var i = 0; i < stringBuilder.Length; i++) 21 | bw.Write(stringBuilder[i]); 22 | 23 | context.LeaveObject(); 24 | } 25 | 26 | [CustomFieldSerializer] 27 | public static void DeserializeField(DeserializeContext context, BinaryReader br, 28 | ref StringBuilder stringBuilder) 29 | { 30 | if (!context.Walk(ref stringBuilder)) 31 | return; 32 | 33 | var length = br.ReadSmallInt32(); 34 | stringBuilder = new StringBuilder(length); 35 | stringBuilder.Length = length; 36 | context.VisitObject(stringBuilder); 37 | for (var i = 0; i < length; i++) 38 | stringBuilder[i] = br.ReadChar(); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Serialization/ImageKey.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Runtime.CompilerServices; 5 | using Microsoft.Xna.Framework; 6 | using Microsoft.Xna.Framework.Graphics; 7 | 8 | namespace Pixel3D.Animations.Serialization 9 | { 10 | struct ImageKey : IEquatable 11 | { 12 | public ImageKey(Texture2D texture, Rectangle sourceRectangle) 13 | { 14 | this.texture = texture; 15 | this.sourceRectangle = sourceRectangle; 16 | } 17 | 18 | Texture2D texture; 19 | Rectangle sourceRectangle; 20 | 21 | 22 | public override int GetHashCode() 23 | { 24 | return RuntimeHelpers.GetHashCode(texture) ^ sourceRectangle.GetHashCode(); 25 | } 26 | 27 | public override bool Equals(object obj) 28 | { 29 | if(obj is ImageKey) 30 | return Equals((ImageKey)obj); 31 | else 32 | return false; 33 | } 34 | 35 | public bool Equals(ImageKey other) // from IEquatable 36 | { 37 | return ReferenceEquals(texture, other.texture) && sourceRectangle == other.sourceRectangle; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Pixel3D.P2P/P2PClientMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | namespace Pixel3D.P2P 5 | { 6 | /// Messages sent from the P2P client to the P2P server 7 | internal enum P2PClientMessage 8 | { 9 | /// 10 | /// Connected to a given peer. 11 | /// 12 | Connected, 13 | 14 | 15 | /// 16 | /// Failed to connect to a given peer or they were disconnected from us. 17 | /// 18 | Disconnected, 19 | 20 | /// 21 | /// If another peer says they've disconnected from us, and we're the "older" 22 | /// of the two peers, the server will give us a chance to say we're still alive. 23 | /// 24 | DisputeDisconnection, 25 | 26 | 27 | /// 28 | /// In what I would consider to be a bug in Lidgren, the RTT is not initialised when a connection is first established. 29 | /// So instead we make it a requirement at the P2P layer to become application-connected. 30 | /// 31 | RTTInitialised, 32 | 33 | 34 | /// 35 | /// Indicate to a recently-host-migrated sever that their host migration request was accepted. 36 | /// 37 | AcceptHostMigration, 38 | 39 | 40 | Unknown 41 | } 42 | } -------------------------------------------------------------------------------- /src/Pixel3D.Pipeline/MaskReadAndDeduplicate.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using Pixel3D.Animations; 5 | 6 | namespace Pixel3D.Pipeline 7 | { 8 | /// 9 | /// Intercept data from the capture stream and replace it with a mask ID 10 | /// 11 | public class MaskReadAndDeduplicate : ICustomMaskDataReader 12 | { 13 | private readonly ByteArrayDeduplicator byteArrayDeduplicator; 14 | private readonly CaptureStream readStream; 15 | 16 | public MaskReadAndDeduplicate(CaptureStream readStream, ByteArrayDeduplicator byteArrayDeduplicator) 17 | { 18 | this.readStream = readStream; 19 | this.byteArrayDeduplicator = byteArrayDeduplicator; 20 | } 21 | 22 | public uint[] Read(int length) 23 | { 24 | // Pull out the original data for the mask: 25 | var originalData = new byte[length * 4]; 26 | readStream.StreamToCapture.Read(originalData, 0, length * 4); 27 | 28 | // Insert it into the mask data deduplicator: 29 | var id = byteArrayDeduplicator.Add(originalData); 30 | 31 | // Write out the deduplicated ID: 32 | readStream.CaptureTarget.Write(BitConverter.GetBytes(id), 0, 4); 33 | 34 | // Return some garbage to keep our caller quiet... 35 | return new uint[length]; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/MethodProviders/LookupMethodProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.Reflection; 7 | 8 | namespace Pixel3D.Serialization.MethodProviders 9 | { 10 | // Generic to support lookups on MethodBuilder 11 | internal class LookupMethodProvider : MethodProvider 12 | { 13 | public readonly Dictionary lookup; 14 | 15 | public LookupMethodProvider() 16 | { 17 | lookup = new Dictionary(); 18 | } 19 | 20 | public LookupMethodProvider(Dictionary lookup) 21 | { 22 | this.lookup = lookup; 23 | } 24 | 25 | public override MethodInfo GetMethodForType(Type type) 26 | { 27 | MethodInfo method; 28 | 29 | if (lookup.TryGetValue(type, out method)) 30 | return method; 31 | 32 | if (type.IsGenericType) 33 | if (lookup.TryGetValue(type.GetGenericTypeDefinition(), out method)) 34 | { 35 | Debug.Assert(method.IsGenericMethodDefinition); 36 | return method.MakeGenericMethod(type.GetGenericArguments()); 37 | } 38 | 39 | return null; 40 | } 41 | 42 | public void Add(Type type, MethodInfo method) 43 | { 44 | lookup.Add(type, method); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Pixel3D/Extensions/PositionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.IO; 4 | using Microsoft.Xna.Framework; 5 | 6 | namespace Pixel3D.Extensions 7 | { 8 | public static class PositionExtensions 9 | { 10 | public static void Write(this BinaryWriter bw, Position position) 11 | { 12 | position.Serialize(bw); 13 | } 14 | 15 | public static Position ReadPosition(this BinaryReader br) 16 | { 17 | return new Position(br); 18 | } 19 | 20 | public static Point GetXY(this Position position) 21 | { 22 | return new Point(position.X, position.Y); 23 | } 24 | 25 | public static Point GetXZ(this Position position) 26 | { 27 | return new Point(position.X, position.Z); 28 | } 29 | 30 | /// Project the point onto the XY plane at depth Z = 0 31 | public static Point ToWorldZero(this Position position) 32 | { 33 | return new Point(position.X, position.Y + position.Z); 34 | } 35 | 36 | /// Project the point onto the XY plane at depth Z = 0, where Y- is up. (Suitable for passing to a SpriteBatch with an appropriate transform.) 37 | public static Vector2 ToDisplay(this Position position) 38 | { 39 | return new Vector2(position.X, -(position.Y + position.Z)); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Pixel3D.Navigation/Pixel3D.Navigation.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Debug;Release;Retail 6 | AnyCPU;x64 7 | 8 | 9 | 10 | TRACE;DEBUG;DEVELOPER 11 | 12 | 13 | 14 | TRACE;DEBUG;DEVELOPER 15 | 16 | 17 | 18 | TRACE;DEVELOPER 19 | 20 | 21 | 22 | TRACE;DEVELOPER 23 | 24 | 25 | 26 | true 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Pixel3D/PanCamera.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Microsoft.Xna.Framework; 4 | using Pixel3D.Extensions; 5 | 6 | namespace Pixel3D 7 | { 8 | public class PanCamera 9 | { 10 | Point worldPanTarget; 11 | 12 | /// Depends on global Input 13 | public void Update(Camera camera) 14 | { 15 | if(Input.MiddleMouseWentDown) 16 | { 17 | SetWorldPanTarget(camera, Input.MousePosition); 18 | } 19 | else if(Input.IsMiddleMouseDown) 20 | { 21 | Pan(camera, Input.MousePosition); 22 | } 23 | } 24 | 25 | public void SetWorldPanTarget(Camera camera, Point mousePosition) 26 | { 27 | worldPanTarget = camera.ScreenToWorldZero(mousePosition); 28 | } 29 | 30 | public void Pan(Camera camera, Point mousePosition) 31 | { 32 | Point current = camera.ScreenToWorldZero(mousePosition); 33 | Point delta = worldPanTarget.Subtract(current); 34 | camera.WorldTarget += new Position(delta.X, delta.Y, 0); 35 | } 36 | 37 | public void Reset(Camera camera) 38 | { 39 | camera.WorldTarget = Position.Zero; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Pixel3D.AssetManagement/Pixel3D.AssetManagement.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Debug;Release;Retail 6 | AnyCPU;x64 7 | 8 | 9 | 10 | TRACE;DEBUG;DEVELOPER 11 | 12 | 13 | 14 | TRACE;DEBUG;DEVELOPER 15 | 16 | 17 | 18 | TRACE;DEVELOPER 19 | 20 | 21 | 22 | TRACE;DEVELOPER 23 | 24 | 25 | 26 | true 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Pixel3D/Animations/Serialization/SimpleTextureLoadHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using Microsoft.Xna.Framework; 4 | using Microsoft.Xna.Framework.Graphics; 5 | 6 | namespace Pixel3D.Animations.Serialization 7 | { 8 | public class SimpleTextureLoadHelper : ITextureLoadHelper 9 | { 10 | public SimpleTextureLoadHelper(byte[] sharedLoadBuffer, GraphicsDevice graphicsDevice) 11 | { 12 | this.sharedLoadBuffer = sharedLoadBuffer; 13 | this.graphicsDevice = graphicsDevice; 14 | } 15 | 16 | public SimpleTextureLoadHelper(GraphicsDevice graphicsDevice) 17 | { 18 | sharedLoadBuffer = new byte[ImageBundleManager.LoadBufferSize]; 19 | this.graphicsDevice = graphicsDevice; 20 | } 21 | 22 | byte[] sharedLoadBuffer; 23 | GraphicsDevice graphicsDevice; 24 | 25 | public byte[] GetSharedLoadBuffer() 26 | { 27 | return sharedLoadBuffer; 28 | } 29 | 30 | public Texture2D LoadTexture(int width, int height, byte[] buffer) 31 | { 32 | var texture = new Texture2D(graphicsDevice, width, height); 33 | texture.SetData(0, new Rectangle(0, 0, width, height), buffer, 0, width * height * 4); 34 | return texture; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Pixel3D.P2P/GameInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | 4 | using Lidgren.Network; 5 | 6 | namespace Pixel3D.P2P 7 | { 8 | public class GameInfo 9 | { 10 | public GameInfo(string name, bool isInternetGame, bool sideChannelAuth) 11 | { 12 | Name = name.FilterName(); 13 | IsInternetGame = isInternetGame; 14 | SideChannelAuth = sideChannelAuth; 15 | } 16 | 17 | public string Name { get; private set; } 18 | public bool IsInternetGame { get; private set; } 19 | public bool SideChannelAuth { get; private set; } 20 | 21 | internal void CopyFrom(GameInfo other) 22 | { 23 | Name = other.Name; 24 | IsInternetGame = other.IsInternetGame; 25 | SideChannelAuth = other.SideChannelAuth; 26 | } 27 | 28 | 29 | #region Network Read/Write 30 | 31 | // Used by "dud" discovered game 32 | internal GameInfo(string name) 33 | { 34 | Name = name; 35 | } 36 | 37 | internal GameInfo(NetIncomingMessage message) 38 | { 39 | Name = message.ReadString().FilterName(); 40 | IsInternetGame = message.ReadBoolean(); 41 | SideChannelAuth = message.ReadBoolean(); 42 | } 43 | 44 | internal void WriteTo(NetOutgoingMessage message) 45 | { 46 | message.Write(Name.FilterName()); 47 | message.Write(IsInternetGame); 48 | message.Write(SideChannelAuth); 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /src/Pixel3D.Audio/FadePitchPan.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | 5 | namespace Pixel3D.Audio 6 | { 7 | /// Convert an audio position to fade/pitch/pan for playback 8 | public struct FadePitchPan 9 | { 10 | public float fade, pitch, pan; 11 | 12 | public FadePitchPan(PitchPan pitchPan) : this(pitchPan.pitch, pitchPan.pitch) { } 13 | 14 | public FadePitchPan(float pitch, float pan) 15 | { 16 | var xFade = Math.Abs(pitch).MapFrom(1.05f, 1.3f).Clamp(); // <- assume horizontal is smaller 17 | var yFade = Math.Abs(pan).MapFrom(1.2f, 1.6f).Clamp(); 18 | fade = ((float) Math.Sqrt(xFade * xFade + yFade * yFade)).Clamp().MapTo(1f, 0f); // <- circular edges 19 | 20 | this.pitch = fade.MapFrom(0f, 0.3f).Clamp().MapTo(-0.15f, 0f); // <- subtle pitch-down effect at the edges :) 21 | 22 | if (pitch < 0) 23 | this.pan = -pan.MapFrom(-0.4f, -1.2f).Clamp(); 24 | else 25 | this.pan = pan.MapFrom(0.4f, 1.2f).Clamp(); 26 | } 27 | 28 | public FadePitchPan(float fade) 29 | { 30 | this.fade = fade; 31 | pitch = 0; 32 | pan = 0; 33 | } 34 | 35 | public void ApplyTo(SafeSoundEffectInstance soundEffectInstance, float mixVolume) 36 | { 37 | soundEffectInstance.Volume = fade * mixVolume; 38 | soundEffectInstance.Pitch = pitch; 39 | soundEffectInstance.Pan = pan; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Content/Content.mgcb: -------------------------------------------------------------------------------- 1 | 2 | #----------------------------- Global Properties ----------------------------# 3 | 4 | /outputDir:bin/Windows 5 | /intermediateDir:obj/Windows 6 | /platform:Windows 7 | /config: 8 | /profile:HiDef 9 | /compress:False 10 | 11 | #-------------------------------- References --------------------------------# 12 | 13 | 14 | #---------------------------------- Content ---------------------------------# 15 | 16 | #begin LargeText.spritefont 17 | /importer:FontDescriptionImporter 18 | /processor:FontDescriptionProcessor 19 | /processorParam:PremultiplyAlpha=True 20 | /processorParam:TextureFormat=Color 21 | /build:LargeText.spritefont 22 | 23 | #begin Sprite.png 24 | /importer:TextureImporter 25 | /processor:TextureProcessor 26 | /processorParam:ColorKeyColor=255,0,255,255 27 | /processorParam:ColorKeyEnabled=False 28 | /processorParam:GenerateMipmaps=False 29 | /processorParam:PremultiplyAlpha=True 30 | /processorParam:ResizeToPowerOfTwo=False 31 | /processorParam:MakeSquare=False 32 | /processorParam:TextureFormat=Color 33 | /build:Sprite.png 34 | 35 | #begin hit.wav 36 | /importer:WavImporter 37 | /processor:SoundEffectProcessor 38 | /processorParam:Quality=Best 39 | /build:hit.wav 40 | 41 | #begin score.wav 42 | /importer:WavImporter 43 | /processor:SoundEffectProcessor 44 | /processorParam:Quality=Best 45 | /build:score.wav 46 | 47 | #begin ready.wav 48 | /importer:WavImporter 49 | /processor:SoundEffectProcessor 50 | /processorParam:Quality=Best 51 | /build:ready.wav -------------------------------------------------------------------------------- /src/Pixel3D.All.XNA/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Pixel3D.XNA")] 9 | [assembly: AssemblyProduct("Pixel3D.XNA")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyCompany("Conatus Creative Inc.")] 12 | [assembly: AssemblyCopyright("Copyright © 2018 Conatus Creative Inc.")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. Only Windows 19 | // assemblies support COM. 20 | [assembly: ComVisible(false)] 21 | 22 | // On Windows, the following GUID is for the ID of the typelib if this 23 | // project is exposed to COM. On other platforms, it unique identifies the 24 | // title storage container when deploying this assembly to the device. 25 | [assembly: Guid("f7258856-9234-4523-a8a9-2fc3230d9906")] 26 | 27 | // Version information for an assembly consists of the following four values: 28 | // 29 | // Major Version 30 | // Minor Version 31 | // Build Number 32 | // Revision 33 | // 34 | [assembly: AssemblyVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Pixel3D.Pipeline/PathGatheringAssetProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using Pixel3D.AssetManagement; 7 | 8 | namespace Pixel3D.Pipeline 9 | { 10 | public class PathGatheringAssetProvider : IAssetProvider 11 | { 12 | public readonly HashSet assetPaths = new HashSet(); 13 | private readonly string assetRoot; 14 | 15 | public PathGatheringAssetProvider(string assetRoot) 16 | { 17 | this.assetRoot = assetRoot; 18 | } 19 | 20 | public T Load(string assetPath) where T : class 21 | { 22 | assetPath = AssetManager.CanonicaliseAssetPath(assetPath); 23 | assetPaths.Add(assetPath + AssetReader.Extension()); 24 | return null; 25 | } 26 | 27 | public ICollection LoadAll() where T : class 28 | { 29 | return YieldAssetsOfType().ToArray(); 30 | } 31 | 32 | private IEnumerable YieldAssetsOfType() where T : class 33 | { 34 | var starDotExtension = "*" + AssetReader.Extension(); 35 | var paths = Directory.GetFiles(assetRoot, starDotExtension, SearchOption.AllDirectories); 36 | foreach (var path in paths) 37 | { 38 | var assetPath = path 39 | .Replace(assetRoot, string.Empty) 40 | .Replace(Path.GetFileName(path), Path.GetFileNameWithoutExtension(path)); 41 | yield return Load(assetPath); 42 | } 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Pixel3D.Editing/Pixel3D.Editing.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Debug;Release;Retail 6 | AnyCPU;x64 7 | 8 | 9 | 10 | TRACE;DEBUG;DEVELOPER 11 | 12 | 13 | 14 | TRACE;DEBUG;DEVELOPER 15 | 16 | 17 | 18 | TRACE;DEVELOPER 19 | 20 | 21 | 22 | TRACE;DEVELOPER 23 | 24 | 25 | 26 | true 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/Pixel3D.Strings/Pixel3D.Strings.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Debug;Release;Retail 6 | AnyCPU;x64 7 | 8 | 9 | 10 | TRACE;DEBUG;DEVELOPER 11 | 12 | 13 | 14 | TRACE;DEBUG;DEVELOPER 15 | 16 | 17 | 18 | TRACE;DEVELOPER 19 | 20 | 21 | 22 | TRACE;DEVELOPER 23 | 24 | 25 | 26 | true 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/Pixel3D.Network.Demo/Common/BinaryReadWriteXNA.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Microsoft.Xna.Framework // Put these methods in the same namespace of their types 4 | { 5 | public static class BinaryReadWriteXNAExtensions 6 | { 7 | public static Color ReadColor(this BinaryReader br) 8 | { 9 | Color c = new Color(); 10 | c.PackedValue = br.ReadUInt32(); 11 | return c; 12 | } 13 | 14 | public static void Write(this BinaryWriter bw, Color c) 15 | { 16 | bw.Write(c.PackedValue); 17 | } 18 | 19 | 20 | 21 | public static Point ReadPoint(this BinaryReader br) 22 | { 23 | Point p; 24 | p.X = br.ReadInt32(); 25 | p.Y = br.ReadInt32(); 26 | return p; 27 | } 28 | 29 | public static void Write(this BinaryWriter bw, Point p) 30 | { 31 | bw.Write(p.X); 32 | bw.Write(p.Y); 33 | } 34 | 35 | 36 | public static Rectangle ReadRectangle(this BinaryReader br) 37 | { 38 | Rectangle r; 39 | r.X = br.ReadInt32(); 40 | r.Y = br.ReadInt32(); 41 | r.Width = br.ReadInt32(); 42 | r.Height = br.ReadInt32(); 43 | return r; 44 | } 45 | 46 | public static void Write(this BinaryWriter bw, Rectangle r) 47 | { 48 | bw.Write(r.X); 49 | bw.Write(r.Y); 50 | bw.Write(r.Width); 51 | bw.Write(r.Height); 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Pixel3D.Serialization/Discovery/DelegateUsageInternal.cs: -------------------------------------------------------------------------------- 1 | // Copyright © Conatus Creative, Inc. All rights reserved. 2 | // Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license terms. 3 | using System; 4 | using System.IO; 5 | using System.Reflection; 6 | using Pixel3D.Serialization.Discovery.ReadIL; 7 | 8 | namespace Pixel3D.Serialization.Discovery 9 | { 10 | internal struct DelegateUsageInternal 11 | { 12 | public MethodBase instantiatingMethod; 13 | public long instantiationILOffset; 14 | 15 | public bool targetTypeKnown; 16 | public Type targetType; 17 | public MethodInfo delegateMethod; 18 | public Type delegateType; 19 | 20 | 21 | public void WriteInfo(StreamWriter writer, bool writeInstantiation = false) 22 | { 23 | var delegateTargetName = targetTypeKnown 24 | ? (targetType != null ? instantiatingMethod.GetLocalNameFor(targetType) : "(null)") 25 | : "*** UNKNOWN TARGET! ***"; 26 | var delegateMethodName = delegateMethod != null 27 | ? instantiatingMethod.GetLocalNameFor(delegateMethod) 28 | : "*** UNKNOWN METHOD! ***"; 29 | var delegateTypeName = instantiatingMethod.GetLocalNameFor(delegateType); 30 | 31 | if (writeInstantiation) 32 | writer.WriteLine(" at IL offset " + instantiationILOffset + " in method " + instantiatingMethod + 33 | " in type " + instantiatingMethod.DeclaringType); 34 | 35 | writer.WriteLine(" T = " + delegateTargetName); 36 | writer.WriteLine(" M = " + delegateMethodName); 37 | writer.WriteLine(" D = " + delegateTypeName); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /test/Pixel3D.Serialization.Demo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("Pixel3D.Serialization.Demo")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("Pixel3D.Serialization.Demo")] 12 | [assembly: AssemblyCopyright("Copyright © Conatus Creative Inc. 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("aa10b68a-81f9-46d8-8272-5cce708eba88")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /src/Pixel3D.ActorManagement/Pixel3D.ActorManagement.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | Pixel3D.ActorManagement 6 | Debug;Release;Retail 7 | AnyCPU;x64 8 | 9 | 10 | 11 | TRACE;DEBUG;DEVELOPER 12 | 13 | 14 | 15 | TRACE;DEBUG;DEVELOPER 16 | 17 | 18 | 19 | TRACE;DEVELOPER 20 | 21 | 22 | 23 | TRACE;DEVELOPER 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | --------------------------------------------------------------------------------