1
0
forked from MTSR/mapserver

fine grained protector selection (overlay and detection)

This commit is contained in:
NatureFreshMilk 2019-02-27 15:50:23 +01:00
parent 16c6f5f065
commit 8631d71429
6 changed files with 77 additions and 1 deletions

View File

@ -31,6 +31,8 @@ type MapBlockAccessorConfig struct {
type MapObjectConfig struct { type MapObjectConfig struct {
Bones bool `json:"bones"` Bones bool `json:"bones"`
Protector bool `json:"protector"` Protector bool `json:"protector"`
XPProtector bool `json:"xpprotector"`
PrivProtector bool `json:"privprotector"`
Technic bool `json:"technic"` Technic bool `json:"technic"`
LuaController bool `json:"luacontroller"` LuaController bool `json:"luacontroller"`
Digiterms bool `json:"digiterms"` Digiterms bool `json:"digiterms"`
@ -106,6 +108,8 @@ func ParseConfig(filename string) (*Config, error) {
mapobjs := MapObjectConfig{ mapobjs := MapObjectConfig{
Bones: true, Bones: true,
Protector: true, Protector: true,
XPProtector: true,
PrivProtector: true,
Technic: true, Technic: true,
LuaController: true, LuaController: true,
Digiterms: true, Digiterms: true,

View File

@ -24,11 +24,19 @@ func Setup(ctx *app.App) {
l.AddMapObject("travelnet:travelnet", &TravelnetBlock{}) l.AddMapObject("travelnet:travelnet", &TravelnetBlock{})
} }
//protections //protector
if ctx.Config.MapObjects.Protector { if ctx.Config.MapObjects.Protector {
l.AddMapObject("protector:protect", &ProtectorBlock{}) l.AddMapObject("protector:protect", &ProtectorBlock{})
l.AddMapObject("protector:protect2", &ProtectorBlock{}) l.AddMapObject("protector:protect2", &ProtectorBlock{})
}
//xp protector
if ctx.Config.MapObjects.XPProtector {
l.AddMapObject("xp_redo:protector", &XPProtectorBlock{}) l.AddMapObject("xp_redo:protector", &XPProtectorBlock{})
}
//priv protector
if ctx.Config.MapObjects.PrivProtector {
l.AddMapObject("priv_protector:protector", &PrivProtectorBlock{}) l.AddMapObject("priv_protector:protector", &PrivProtectorBlock{})
} }

View File

@ -38,6 +38,8 @@
<script src="js/overlays/PlayerOverlay.js"></script> <script src="js/overlays/PlayerOverlay.js"></script>
<script src="js/overlays/TrainOverlay.js"></script> <script src="js/overlays/TrainOverlay.js"></script>
<script src="js/overlays/ProtectorOverlay.js"></script> <script src="js/overlays/ProtectorOverlay.js"></script>
<script src="js/overlays/XPProtectorOverlay.js"></script>
<script src="js/overlays/PrivProtectorOverlay.js"></script>
<script src="js/overlays/BonesOverlay.js"></script> <script src="js/overlays/BonesOverlay.js"></script>
<script src="js/overlays/LcdOverlay.js"></script> <script src="js/overlays/LcdOverlay.js"></script>
<script src="js/overlays/DigitermOverlay.js"></script> <script src="js/overlays/DigitermOverlay.js"></script>

View File

@ -42,6 +42,14 @@ function Overlaysetup(cfg, map, overlays, wsChannel, layerMgr){
overlays["Protector"] = new ProtectorOverlay(wsChannel, layerMgr); overlays["Protector"] = new ProtectorOverlay(wsChannel, layerMgr);
} }
if (cfg.mapobjects.xpprotector) {
overlays["XP Protector"] = new XPProtectorOverlay(wsChannel, layerMgr);
}
if (cfg.mapobjects.privprotector) {
overlays["Priv Protector"] = new PrivProtectorOverlay(wsChannel, layerMgr);
}
if (cfg.mapobjects.mission) { if (cfg.mapobjects.mission) {
overlays["Missions"] = new MissionOverlay(wsChannel, layerMgr); overlays["Missions"] = new MissionOverlay(wsChannel, layerMgr);
} }

View File

@ -0,0 +1,27 @@
'use strict';
var PrivProtectorOverlay = AbstractGeoJsonOverlay.extend({
initialize: function(wsChannel, layerMgr) {
AbstractGeoJsonOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "privprotector");
},
createFeature: function(protector){
return {
"type":"Feature",
"geometry": {
"type":"Polygon",
"coordinates":[[
[protector.x-5,protector.z-5],
[protector.x-5,protector.z+6],
[protector.x+6,protector.z+6],
[protector.x+6,protector.z-5],
[protector.x-5,protector.z-5]
]]
},
"properties":{
"name": protector.attributes.priv,
"popupContent": protector.attributes.priv
}
};
}
});

View File

@ -0,0 +1,27 @@
'use strict';
var XPProtectorOverlay = AbstractGeoJsonOverlay.extend({
initialize: function(wsChannel, layerMgr) {
AbstractGeoJsonOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "xpprotector");
},
createFeature: function(protector){
return {
"type":"Feature",
"geometry": {
"type":"Polygon",
"coordinates":[[
[protector.x-5,protector.z-5],
[protector.x-5,protector.z+6],
[protector.x+6,protector.z+6],
[protector.x+6,protector.z-5],
[protector.x-5,protector.z-5]
]]
},
"properties":{
"name": protector.attributes.xpthreshold,
"popupContent": protector.attributes.xpthreshold
}
};
}
});